From fc76b6c4a7ccd2d875b0fb998a868fe4bea188f7 Mon Sep 17 00:00:00 2001 From: 朱桂飞 <zhuguifei@zhuguifeideMacBook-Air.local> Date: 星期五, 14 二月 2025 09:19:18 +0800 Subject: [PATCH] 新增设备台账导入 --- eims/ruoyi-modules/lb-eims/src/main/java/org/dromara/eims/controller/EimsEquController.java | 28 + eims/ruoyi-modules/lb-eims/src/main/java/org/dromara/eims/domain/vo/EimsEquImportVo.java | 141 ++++++ eims-ui/apps/web-antd/src/views/eims/components/user-modal.vue | 49 ++ eims-ui/apps/web-antd/src/views/eims/equ/equ-import-modal.vue | 112 +++++ eims-ui/apps/web-antd/src/views/eims/equ/data.tsx | 93 +++ eims/ruoyi-modules/lb-eims/src/main/java/org/dromara/eims/service/IEimsEquService.java | 8 eims/ruoyi-modules/lb-eims/src/main/java/org/dromara/eims/service/impl/EimsEquServiceImpl.java | 17 eims/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/constant/CacheConstants.java | 10 eims-ui/apps/web-antd/src/views/eims/equ/equ-drawer.vue | 66 ++ eims-ui/apps/web-antd/src/views/eims/repair-req/data.tsx | 6 eims-ui/apps/web-antd/src/views/eims/repair-req/index.vue | 4 eims-ui/packages/@core/base/shared/src/constants/dict-enum.ts | 4 eims-ui/packages/effects/request/src/request-client/request-client.ts | 2 eims/ruoyi-modules/lb-eims/src/main/java/org/dromara/eims/domain/bo/EimsEquBo.java | 37 + eims-ui/apps/web-antd/src/api/eims/equ/index.ts | 37 + eims-ui/apps/web-antd/src/views/system/user/index.vue | 128 +---- eims-ui/apps/web-antd/src/api/eims/equ/model.d.ts | 9 eims/ruoyi-modules/lb-eims/src/main/java/org/dromara/eims/domain/vo/EimsEquVo.java | 233 ++++++--- eims-ui/apps/web-antd/src/views/eims/equ/index.vue | 28 eims-ui/apps/web-antd/src/views/eims/repair-req/use-role-base-filters.ts | 26 + eims/ruoyi-modules/lb-eims/src/main/java/org/dromara/eims/domain/EimsEqu.java | 31 + eims/ruoyi-modules/lb-eims/pom.xml | 4 eims/ruoyi-modules/lb-eims/src/main/java/org/dromara/eims/listener/EimsEquImportListener.java | 181 ++++++++ eims/ruoyi-modules/lb-eims/src/main/java/org/dromara/eims/service/impl/EimsRepairReqServiceImpl.java | 26 24 files changed, 1,055 insertions(+), 225 deletions(-) diff --git a/eims-ui/apps/web-antd/src/api/eims/equ/index.ts b/eims-ui/apps/web-antd/src/api/eims/equ/index.ts index fd95bcd..b797795 100644 --- a/eims-ui/apps/web-antd/src/api/eims/equ/index.ts +++ b/eims-ui/apps/web-antd/src/api/eims/equ/index.ts @@ -1,13 +1,15 @@ import type { IDS, PageQuery, PageResult } from '#/api/common'; -import type { EquVO } from '#/api/eims/equ/model'; +import type { EquImportParam, EquVO } from '#/api/eims/equ/model'; -import { commonExport } from '#/api/helper'; +import { commonExport, ContentTypeEnum } from '#/api/helper'; import { requestClient } from '#/api/request'; enum Api { equExport = '/eims/equ/export', + equImport = '/eims/equ/importData', equList = '/eims/equ/list', - root = '/eims/equ' + root = '/eims/equ', + userImportTemplate = '/eims/equ/importTemplate' } /** @@ -59,3 +61,32 @@ export function equExport(data: any) { return commonExport(Api.equExport, data); } + +/** + * 浠巈xcel瀵煎叆璁惧 + * @param data + * @returns void + */ +export function equImportData(data: EquImportParam) { + return requestClient.post<{ code: number; msg: string }>(Api.equImport, data, { + headers: { + 'Content-Type': ContentTypeEnum.FORM_DATA + }, + isTransformResponse: false + }); +} + +/** + * 涓嬭浇瀵煎叆妯℃澘 + * @returns blob + */ +export function downloadImportTemplate() { + return requestClient.post<Blob>( + Api.userImportTemplate, + {}, + { + isTransformResponse: false, + responseType: 'blob' + } + ); +} diff --git a/eims-ui/apps/web-antd/src/api/eims/equ/model.d.ts b/eims-ui/apps/web-antd/src/api/eims/equ/model.d.ts index 7807f19..c2eb4a8 100644 --- a/eims-ui/apps/web-antd/src/api/eims/equ/model.d.ts +++ b/eims-ui/apps/web-antd/src/api/eims/equ/model.d.ts @@ -122,3 +122,12 @@ */ serviceLife: number; } +/** + * @description: 璁惧瀵煎叆 + * @param updateSupport 鏄惁瑕嗙洊鏁版嵁 + * @param file excel鏂囦欢 + */ +export interface EquImportParam { + updateSupport: boolean; + file: Blob | File; +} diff --git a/eims-ui/apps/web-antd/src/views/eims/components/user-modal.vue b/eims-ui/apps/web-antd/src/views/eims/components/user-modal.vue new file mode 100644 index 0000000..70cf5c4 --- /dev/null +++ b/eims-ui/apps/web-antd/src/views/eims/components/user-modal.vue @@ -0,0 +1,49 @@ +<script setup lang="ts"> +import { ref } from 'vue'; + +import { useVbenModal } from '@vben/common-ui'; + +import { message } from 'ant-design-vue'; + +import UserView from '#/views/system/user/index.vue'; + +const emit = defineEmits<{ selectUser: [any] }>(); + +const [BasicModal, modalApi] = useVbenModal({ + fullscreenButton: false, + draggable: true, + onCancel: handleCancel, + onConfirm: handleConfirm +}); +const userView = ref(); + +async function handleConfirm() { + try { + modalApi.modalLoading(true); + const tableSelect = userView.value.tableSelect(); + if (tableSelect.length > 1) { + message.error('鏈�澶氬彧鑳介�夋嫨涓�涓垚鍛橈紒'); + modalApi.modalLoading(false); + return false; + } + emit('selectUser', tableSelect[0]); + await handleCancel(); + } catch (error) { + console.error(error); + } finally { + modalApi.modalLoading(false); + } +} + +async function handleCancel() { + modalApi.close(); +} +</script> + +<template> + <BasicModal :fullscreen-button="true" class="w-[800px]"> + <UserView ref="userView" /> + </BasicModal> +</template> + +<style scoped></style> diff --git a/eims-ui/apps/web-antd/src/views/eims/equ/data.tsx b/eims-ui/apps/web-antd/src/views/eims/equ/data.tsx index f73fc31..f973b4a 100644 --- a/eims-ui/apps/web-antd/src/views/eims/equ/data.tsx +++ b/eims-ui/apps/web-antd/src/views/eims/equ/data.tsx @@ -38,7 +38,7 @@ { title: '璁惧鍚嶇О', field: 'equName', - minWidth: 100, + minWidth: 140, fixed: 'left', slots: { default: 'equName' } }, @@ -49,6 +49,9 @@ sortable: true, slots: { default: ({ row }) => { + if (row.status === null || row.status === '') { + return ''; + } return renderDict(row.status, DictEnum.SYS_EQU_STATUS); } }, @@ -59,7 +62,7 @@ title: '璧勪骇缂栧彿', field: 'assetNo', sortable: true, - minWidth: 100, + minWidth: 140, fixed: 'left' }, { @@ -71,6 +74,31 @@ { title: '璁惧绫诲瀷', field: 'equTypeName', + minWidth: 100 + }, + { + title: '閿�鍞晢', + field: 'seller', + minWidth: 100 + }, + { + title: '鍗曚綅', + field: 'unit', + minWidth: 60 + }, + { + title: '閲囪喘浜�', + field: 'purchaseUser', + minWidth: 100 + }, + { + title: '缁忔墜浜�', + field: 'handleUser', + minWidth: 100 + }, + { + title: '璧勬枡', + field: 'profile', minWidth: 100 }, { @@ -142,13 +170,21 @@ { title: '瀵煎叆鐘舵��', field: 'importStatus', - slots: { default: 'importStatus' }, + slots: { + default: ({ row }) => { + return row.importStatus === null || row.importStatus === '' ? '' : renderDict(row.importStatus, DictEnum.EQU_IMPORT_STATU); + } + }, minWidth: 100 }, { title: '鐩樼偣鏍囧織', field: 'inventoryFlag', - slots: { default: 'inventoryFlag' }, + slots: { + default: ({ row }) => { + return row.inventoryFlag === null || row.inventoryFlag === '' ? '' : renderDict(row.inventoryFlag, DictEnum.EIMS_INVENTORY_STATU); + } + }, minWidth: 100 }, { @@ -209,6 +245,42 @@ label: '璧勪骇缂栧彿' }, { + component: 'Select', + componentProps: { + options: getDictOptions(DictEnum.EIMS_EQU_UNIT) + }, + fieldName: 'unit', + label: '鍗曚綅' + }, + { + component: 'Input', + fieldName: 'purchaseUserName', + label: '閲囪喘浜�' + }, + { + component: 'Input', + fieldName: 'purchaseUser', + label: '閲囪喘浜�', + dependencies: { + show: () => false, + triggerFields: [''] + } + }, + { + component: 'Input', + fieldName: 'handleUserName', + label: '缁忔墜浜�' + }, + { + component: 'Input', + fieldName: 'handleUser', + label: '缁忔墜浜�', + dependencies: { + show: () => false, + triggerFields: [''] + } + }, + { component: 'Input', fieldName: 'modelNo', label: '鍨嬪彿' @@ -217,6 +289,11 @@ component: 'Input', fieldName: 'madeIn', label: '鍒堕�犲晢' + }, + { + component: 'Input', + fieldName: 'seller', + label: '閿�鍞晢' }, { component: 'Input', @@ -246,7 +323,7 @@ options: getDictOptions(DictEnum.SYS_EQU_STATUS), optionType: 'button' }, - defaultValue: '0', + defaultValue: '5', fieldName: 'status', label: '鐘舵��' }, @@ -335,7 +412,7 @@ component: 'RadioGroup', componentProps: { buttonStyle: 'solid', - options: getDictOptions(DictEnum.SYS_NORMAL_DISABLE), + options: getDictOptions(DictEnum.EQU_IMPORT_STATU), optionType: 'button' }, defaultValue: '0', @@ -353,12 +430,12 @@ component: 'RadioGroup', componentProps: { buttonStyle: 'solid', - options: getDictOptions(DictEnum.SYS_NORMAL_DISABLE), + options: getDictOptions(DictEnum.EIMS_INVENTORY_STATU), optionType: 'button' }, defaultValue: '0', fieldName: 'inventoryFlag', - formItemClass: 'col-span-2 lg:col-span-1', + formItemClass: 'col-span-2', label: '鐩樼偣鏍囧織' }, { diff --git a/eims-ui/apps/web-antd/src/views/eims/equ/equ-drawer.vue b/eims-ui/apps/web-antd/src/views/eims/equ/equ-drawer.vue index eafef4a..8533537 100644 --- a/eims-ui/apps/web-antd/src/views/eims/equ/equ-drawer.vue +++ b/eims-ui/apps/web-antd/src/views/eims/equ/equ-drawer.vue @@ -1,14 +1,17 @@ <script setup lang="ts"> import { computed, ref } from 'vue'; -import { useVbenDrawer } from '@vben/common-ui'; +import { useVbenDrawer, useVbenModal } from '@vben/common-ui'; import { $t } from '@vben/locales'; import { addFullName, cloneDeep, getPopupContainer, listToTree } from '@vben/utils'; + +import { InputSearch } from 'ant-design-vue'; import { useVbenForm } from '#/adapter/form'; import { addEqu, getEqu, updateEqu } from '#/api/eims/equ'; import { getEquType, listEquType } from '#/api/eims/equ-type'; import { getDeptTree, userList } from '#/api/system/user'; +import userModal from '#/views/eims/components/user-modal.vue'; import { drawerSchema } from './data'; @@ -51,10 +54,9 @@ if (isUpdate.value && id) { const record = await getEqu(id); await formApi.setValues(record); - if(isUpdate.value && record.deptUsed){ - await setupUserOptions(record.deptUsed) + if (isUpdate.value && record.deptUsed) { + await setupUserOptions(record.deptUsed); } - } // 鍔犺浇璁惧绫诲瀷鏍戦�夋嫨 @@ -70,6 +72,38 @@ } }); +// user modal +const [UserModal, userModalApi] = useVbenModal({ + connectedComponent: userModal, + draggable: true, + title: '閫夋嫨鎴愬憳' +}); + +function handleOpenModal() { + userModalApi.setData({}); + userModalApi.open(); +} + +/** + * 鎵撳紑閫夋嫨鎴愬憳 + */ +const column = ref<string>(); +function onOpenSelectUser(type: any) { + column.value = type; + handleOpenModal(); +} + +/** + * 鏇存柊閫夋嫨鐨勬垚鍛� + * @param user + */ +async function selectUser(user: any) { + if (column.value === 'purchaseUser') { + await formApi.setValues({ 'purchaseUser': user.userId, 'purchaseUserName': user.nickName }); + } else if (column.value === 'handleUserName') { + await formApi.setValues({ 'handleUser': user.userId, 'handleUserName': user.nickName }); + } +} async function setupEquTypeSelect() { // status-0 鍙煡璇㈡湭鍋滅敤璁惧 @@ -83,8 +117,8 @@ { equTypeId: 0, typeName: $t('menu.root'), - children: equTree, - }, + children: equTree + } ]; addFullName(fullEquTree, 'typeName', ' / '); formApi.updateSchema([ @@ -92,7 +126,7 @@ componentProps: { fieldNames: { label: 'typeName', - value: 'equTypeId', + value: 'equTypeId' }, getPopupContainer, // 璁剧疆寮圭獥婊氬姩楂樺害 榛樿256 @@ -106,10 +140,10 @@ treeLine: { showLeafIcon: false }, // 绛涢�夌殑瀛楁 treeNodeFilterProp: 'typeName', - treeNodeLabelProp: 'fullName', + treeNodeLabelProp: 'fullName' }, - fieldName: 'equTypeId', - }, + fieldName: 'equTypeId' + } ]); } @@ -135,7 +169,7 @@ const placeholder = options.length > 0 ? '璇烽�夋嫨' : '璇ラ儴闂ㄤ笅鏆傛棤鐢ㄦ埛'; formApi.updateSchema([ { - componentProps: { options, placeholder ,filterOption }, + componentProps: { options, placeholder, filterOption }, fieldName: 'respPerson' } ]); @@ -206,6 +240,14 @@ <template> <BasicDrawer :close-on-click-modal="false" :title="title" class="w-[600px]"> - <BasicForm /> + <BasicForm> + <template #purchaseUserName="slotProps"> + <InputSearch :enter-button="true" placeholder="璇烽�夋嫨" @search="onOpenSelectUser('purchaseUser')" v-bind="slotProps" /> + </template> + <template #handleUserName="slotProps"> + <InputSearch :enter-button="true" placeholder="璇烽�夋嫨" @search="onOpenSelectUser('handleUserName')" v-bind="slotProps" /> + </template> + </BasicForm> + <UserModal class="w-[1200px]" @select-user="selectUser" /> </BasicDrawer> </template> diff --git a/eims-ui/apps/web-antd/src/views/eims/equ/equ-import-modal.vue b/eims-ui/apps/web-antd/src/views/eims/equ/equ-import-modal.vue new file mode 100644 index 0000000..e0f1e9e --- /dev/null +++ b/eims-ui/apps/web-antd/src/views/eims/equ/equ-import-modal.vue @@ -0,0 +1,112 @@ +<script setup lang="ts"> +import type { UploadFile } from 'ant-design-vue/es/upload/interface'; + +import { h, ref, unref } from 'vue'; + +import { useVbenModal } from '@vben/common-ui'; +import { ExcelIcon, InBoxIcon } from '@vben/icons'; + +import { Modal, Switch, Upload } from 'ant-design-vue'; + +import { downloadImportTemplate, equImportData } from '#/api/eims/equ'; +import { commonDownloadExcel } from '#/utils/file/download'; + +const emit = defineEmits<{ reload: [] }>(); + +const UploadDragger = Upload.Dragger; + +const [BasicModal, modalApi] = useVbenModal({ + onCancel: handleCancel, + onConfirm: handleSubmit, +}); + +const fileList = ref<UploadFile[]>([]); +const checked = ref(false); + +async function handleSubmit() { + try { + modalApi.modalLoading(true); + if (fileList.value.length !== 1) { + handleCancel(); + return; + } + const data = { + file: fileList.value[0]!.originFileObj as Blob, + updateSupport: unref(checked), + }; + const { code, msg } = await equImportData(data); + let modal = Modal.success; + if (code === 200) { + emit('reload'); + } else { + emit('reload'); + modal = Modal.error; + } + handleCancel(); + modal({ + content: h('div', { + class: 'max-h-[260px] overflow-y-auto', + innerHTML: msg, // 鍚庡彴宸茬粡澶勭悊xss闂 + }), + title: '鎻愮ず', + }); + } catch (error) { + console.warn(error); + modalApi.close(); + } finally { + modalApi.modalLoading(false); + } +} + +function handleCancel() { + modalApi.close(); + fileList.value = []; + checked.value = false; +} +</script> + +<template> + <BasicModal + :close-on-click-modal="false" + :fullscreen-button="false" + title="璁惧瀵煎叆" + > + <!-- z-index涓嶈缃細閬尅妯℃澘涓嬭浇loading --> + <!-- 鎵嬪姩澶勭悊 鑰屼笉鏄斁鍏ユ枃浠跺氨涓婁紶 --> + <UploadDragger + v-model:file-list="fileList" + :before-upload="() => false" + :max-count="1" + :show-upload-list="true" + accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel" + > + <p class="ant-upload-drag-icon flex items-center justify-center"> + <InBoxIcon class="text-primary size-[48px]" /> + </p> + <p class="ant-upload-text">鐐瑰嚮鎴栬�呮嫋鎷藉埌姝ゅ涓婁紶鏂囦欢</p> + </UploadDragger> + <div class="mt-2 flex flex-col gap-2"> + <div class="flex items-center gap-2"> + <span>鍏佽瀵煎叆xlsx, xls鏂囦欢</span> + <a-button + type="link" + @click="commonDownloadExcel(downloadImportTemplate, '璁惧瀵煎叆妯℃澘')" + > + <div class="flex items-center gap-[4px]"> + <ExcelIcon /> + <span>涓嬭浇妯℃澘</span> + </div> + </a-button> + </div> + <div class="flex items-center gap-2"> + <span class="text-red-500">鈿狅笍鐗瑰埆娉ㄦ剰鈿狅笍锛氳涓嬭浇妯$増淇濇寔瀵煎叆鏂囦欢琛ㄥご鍜屾ā鐗堜竴鑷村悗瀵煎叆</span> + </div> + <div class="flex items-center gap-2"> + <span :class="{ 'text-red-500': checked }"> + 鏄惁鏇存柊/瑕嗙洊宸插瓨鍦ㄧ殑鐢ㄦ埛鏁版嵁 + </span> + <Switch v-model:checked="checked" /> + </div> + </div> + </BasicModal> +</template> diff --git a/eims-ui/apps/web-antd/src/views/eims/equ/index.vue b/eims-ui/apps/web-antd/src/views/eims/equ/index.vue index 1dd8597..1dc33e5 100644 --- a/eims-ui/apps/web-antd/src/views/eims/equ/index.vue +++ b/eims-ui/apps/web-antd/src/views/eims/equ/index.vue @@ -4,7 +4,8 @@ import { ref } from 'vue'; import { useRouter } from 'vue-router'; -import { Page, useVbenDrawer, type VbenFormProps } from '@vben/common-ui'; +import { Page, useVbenDrawer, useVbenModal, type VbenFormProps } from '@vben/common-ui'; +import { $t } from '@vben/locales'; import { getVxePopupContainer } from '@vben/utils'; import { Modal, Popconfirm, Space } from 'ant-design-vue'; @@ -15,6 +16,7 @@ import { columns, querySchema } from './data'; import equDrawer from './equ-drawer.vue'; +import equImportModal from './equ-import-modal.vue'; import EquTypeTree from './equ-type-tree.vue'; // 宸﹁竟閮ㄩ棬鐢� @@ -101,6 +103,17 @@ connectedComponent: equDrawer }); +/** + * 瀵煎叆 + */ +const [EquImportModal, equImportModalApi] = useVbenModal({ + connectedComponent: equImportModal +}); + +function handleImport() { + equImportModalApi.open(); +} + function handleAdd() { equDrawerApi.setData({}); equDrawerApi.open(); @@ -141,11 +154,6 @@ return importStatus ? '鏈鍏�' : '宸插鍏�'; } -function getInventoryFlag(row: any) { - const inventoryFlag = row.inventoryFlag === null || row.inventoryFlag; - return inventoryFlag ? '鏈洏鐐�' : '宸茬洏鐐�'; -} - const router = useRouter(); function handleDetail(record: Recordable<any>) { router.push(`/equ/detail/${record.equId}`); @@ -165,6 +173,9 @@ <Space> <a-button v-access:code="['eims:equ:export']" @click="handleDownloadExcel"> {{ $t('pages.common.export') }} + </a-button> + <a-button v-access:code="['eims:equ:import']" @click="handleImport"> + {{ $t('pages.common.import') }} </a-button> <a-button :disabled="!vxeCheckboxChecked(tableApi)" danger type="primary" v-access:code="['eims:equ:remove']" @click="handleMultiDelete"> {{ $t('pages.common.delete') }} @@ -200,12 +211,9 @@ <template #importStatus="{ row }"> <span>{{ getImportStatus(row) }}</span> </template> - - <template #inventoryFlag="{ row }"> - <span>{{ getInventoryFlag(row) }}</span> - </template> </BasicTable> </div> <EquDrawer @reload="tableApi.query()" /> + <EquImportModal @reload="tableApi.query()" /> </Page> </template> diff --git a/eims-ui/apps/web-antd/src/views/eims/repair-req/data.tsx b/eims-ui/apps/web-antd/src/views/eims/repair-req/data.tsx index 3be5e5f..6f7f556 100644 --- a/eims-ui/apps/web-antd/src/views/eims/repair-req/data.tsx +++ b/eims-ui/apps/web-antd/src/views/eims/repair-req/data.tsx @@ -108,6 +108,12 @@ minWidth: 200 }, { + title: '璁惧鍚嶇О', + field: 'equName', + sortable: true, + minWidth: 120 + }, + { title: '鏁呴殰绫诲埆', field: 'faultType', minWidth: 100, diff --git a/eims-ui/apps/web-antd/src/views/eims/repair-req/index.vue b/eims-ui/apps/web-antd/src/views/eims/repair-req/index.vue index 14bf3ea..d248376 100644 --- a/eims-ui/apps/web-antd/src/views/eims/repair-req/index.vue +++ b/eims-ui/apps/web-antd/src/views/eims/repair-req/index.vue @@ -13,6 +13,7 @@ import { delRepairReq, listRepairReq, repairReqExport } from '#/api/eims/repair-req'; import { getDeptTree, userList } from '#/api/system/user'; import { commonDownloadExcel } from '#/utils/file/download'; +import { useRoleBaseFilters } from '#/views/eims/repair-req/use-role-base-filters'; import { columns, querySchema } from './data'; import repairReqDrawer from './repair-req-drawer.vue'; @@ -50,7 +51,8 @@ return await listRepairReq({ pageNum: page.currentPage, pageSize: page.pageSize, - ...formValues + ...formValues, + ...useRoleBaseFilters() }); } } diff --git a/eims-ui/apps/web-antd/src/views/eims/repair-req/use-role-base-filters.ts b/eims-ui/apps/web-antd/src/views/eims/repair-req/use-role-base-filters.ts new file mode 100644 index 0000000..80e948d --- /dev/null +++ b/eims-ui/apps/web-antd/src/views/eims/repair-req/use-role-base-filters.ts @@ -0,0 +1,26 @@ +import { computed } from 'vue'; + +import { useAccess } from '@vben/access'; +import { useUserStore } from '@vben/stores'; + +const userStore = useUserStore(); +const userId = userStore.userInfo?.userId; + +const { hasAccessByRoles } = useAccess(); +// 鎿嶄綔宸� +const operator = computed(() => hasAccessByRoles(['operator'])); +// 缁翠慨宸� +const repair = computed(() => hasAccessByRoles(['repair'])); + +export function useRoleBaseFilters() { + const params: any = {}; + // 鎿嶄綔宸ュ彧鑳芥煡璇㈣嚜宸卞垱寤虹殑鏁版嵁 + if (operator.value) { + params.createBy = userId; + } + // 缁翠慨宸ュ彧鑳芥煡璇㈡湭鎺ュ崟鐘舵�佺殑鎶ヤ慨鍗曪紙鍏蜂綋鐘舵�佸弬鍔犲瓧鍏竢epair_req_status锛� + if (repair.value) { + params.status = '0'; + } + return { params }; +} diff --git a/eims-ui/apps/web-antd/src/views/system/user/index.vue b/eims-ui/apps/web-antd/src/views/system/user/index.vue index 24b0ed1..b11e5a9 100644 --- a/eims-ui/apps/web-antd/src/views/system/user/index.vue +++ b/eims-ui/apps/web-antd/src/views/system/user/index.vue @@ -4,34 +4,16 @@ import { ref } from 'vue'; import { useAccess } from '@vben/access'; -import { - Page, - useVbenDrawer, - useVbenModal, - type VbenFormProps, -} from '@vben/common-ui'; +import { Page, useVbenDrawer, useVbenModal, type VbenFormProps } from '@vben/common-ui'; import { $t } from '@vben/locales'; import { preferences } from '@vben/preferences'; import { getVxePopupContainer } from '@vben/utils'; -import { - Avatar, - Dropdown, - Menu, - MenuItem, - Modal, - Popconfirm, - Space, -} from 'ant-design-vue'; +import { Avatar, Dropdown, Menu, MenuItem, Modal, Popconfirm, Space } from 'ant-design-vue'; import { useVbenVxeGrid, type VxeGridProps } from '#/adapter/vxe-table'; import { vxeCheckboxChecked } from '#/adapter/vxe-table'; -import { - userExport, - userList, - userRemove, - userStatusChange, -} from '#/api/system/user'; +import { userExport, userList, userRemove, userStatusChange } from '#/api/system/user'; import { TableSwitch } from '#/components/table'; import { commonDownloadExcel } from '#/utils/file/download'; @@ -46,7 +28,7 @@ * 瀵煎叆 */ const [UserImpotModal, userImportModalApi] = useVbenModal({ - connectedComponent: userImportModal, + connectedComponent: userImportModal }); function handleImport() { @@ -55,14 +37,17 @@ // 宸﹁竟閮ㄩ棬鐢� const selectDeptId = ref<string[]>([]); +defineExpose({ + tableSelect +}); const formOptions: VbenFormProps = { schema: querySchema(), commonConfig: { labelWidth: 80, componentProps: { - allowClear: true, - }, + allowClear: true + } }, wrapperClass: 'grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4', handleReset: async () => { @@ -75,13 +60,7 @@ await reload(formValues); }, // 鏃ユ湡閫夋嫨鏍煎紡鍖� - fieldMappingTime: [ - [ - 'createTime', - ['params[beginTime]', 'params[endTime]'], - ['YYYY-MM-DD 00:00:00', 'YYYY-MM-DD 23:59:59'], - ], - ], + fieldMappingTime: [['createTime', ['params[beginTime]', 'params[endTime]'], ['YYYY-MM-DD 00:00:00', 'YYYY-MM-DD 23:59:59']]] }; const gridOptions: VxeGridProps = { @@ -92,7 +71,7 @@ reserve: true, // 鐐瑰嚮琛岄�変腑 trigger: 'default', - checkMethod: ({ row }) => row?.userId !== 1, + checkMethod: ({ row }) => row?.userId !== 1 }, columns, height: 'auto', @@ -111,25 +90,25 @@ return await userList({ pageNum: page.currentPage, pageSize: page.pageSize, - ...formValues, + ...formValues }); - }, - }, + } + } }, rowConfig: { isHover: true, keyField: 'userId', - height: 48, + height: 48 }, - id: 'system-user-index', + id: 'system-user-index' }; const [BasicTable, tableApi] = useVbenVxeGrid({ formOptions, - gridOptions, + gridOptions }); const [UserDrawer, userDrawerApi] = useVbenDrawer({ - connectedComponent: userDrawer, + connectedComponent: userDrawer }); function handleAdd() { @@ -157,18 +136,18 @@ onOk: async () => { await userRemove(ids); await tableApi.query(); - }, + } }); } function handleDownloadExcel() { commonDownloadExcel(userExport, '鐢ㄦ埛绠$悊', tableApi.formApi.form.values, { - fieldMappingTime: formOptions.fieldMappingTime, + fieldMappingTime: formOptions.fieldMappingTime }); } const [UserInfoModal, userInfoModalApi] = useVbenModal({ - connectedComponent: userInfoModal, + connectedComponent: userInfoModal }); function handleUserInfo(row: Recordable<any>) { userInfoModalApi.setData({ userId: row.userId }); @@ -176,12 +155,17 @@ } const [UserResetPwdModal, userResetPwdModalApi] = useVbenModal({ - connectedComponent: userResetPwdModal, + connectedComponent: userResetPwdModal }); function handleResetPwd(record: Recordable<any>) { userResetPwdModalApi.setData({ record }); userResetPwdModalApi.open(); +} + +// 閫変腑鏁版嵁 +function tableSelect() { + return tableApi.grid.getCheckboxRecords(); } const { hasAccessByCodes } = useAccess(); @@ -190,25 +174,14 @@ <template> <Page :auto-content-height="true"> <div class="flex h-full gap-[8px]"> - <DeptTree - v-model:select-dept-id="selectDeptId" - class="w-[260px]" - @reload="() => tableApi.reload()" - @select="() => tableApi.reload()" - /> + <DeptTree v-model:select-dept-id="selectDeptId" class="w-[260px]" @reload="() => tableApi.reload()" @select="() => tableApi.reload()" /> <BasicTable class="flex-1 overflow-hidden" table-title="鐢ㄦ埛鍒楄〃"> <template #toolbar-tools> <Space> - <a-button - v-access:code="['system:user:export']" - @click="handleDownloadExcel" - > + <a-button v-access:code="['system:user:export']" @click="handleDownloadExcel"> {{ $t('pages.common.export') }} </a-button> - <a-button - v-access:code="['system:user:import']" - @click="handleImport" - > + <a-button v-access:code="['system:user:import']" @click="handleImport"> {{ $t('pages.common.import') }} </a-button> <a-button @@ -220,11 +193,7 @@ > {{ $t('pages.common.delete') }} </a-button> - <a-button - type="primary" - v-access:code="['system:user:add']" - @click="handleAdd" - > + <a-button type="primary" v-access:code="['system:user:add']" @click="handleAdd"> {{ $t('pages.common.add') }} </a-button> </Space> @@ -237,49 +206,28 @@ <TableSwitch v-model="row.status" :api="() => userStatusChange(row)" - :disabled=" - row.userId === 1 || !hasAccessByCodes(['system:user:edit']) - " + :disabled="row.userId === 1 || !hasAccessByCodes(['system:user:edit'])" :reload="() => tableApi.query()" /> </template> <template #action="{ row }"> <template v-if="row.userId !== 1"> <Space> - <ghost-button - v-access:code="['system:user:edit']" - @click.stop="handleEdit(row)" - > + <ghost-button v-access:code="['system:user:edit']" @click.stop="handleEdit(row)"> {{ $t('pages.common.edit') }} </ghost-button> - <Popconfirm - :get-popup-container="getVxePopupContainer" - placement="left" - title="纭鍒犻櫎锛�" - @confirm="handleDelete(row)" - > - <ghost-button - danger - v-access:code="['system:user:remove']" - @click.stop="" - > + <Popconfirm :get-popup-container="getVxePopupContainer" placement="left" title="纭鍒犻櫎锛�" @confirm="handleDelete(row)"> + <ghost-button danger v-access:code="['system:user:remove']" @click.stop=""> {{ $t('pages.common.delete') }} </ghost-button> </Popconfirm> </Space> - <Dropdown - :get-popup-container="getVxePopupContainer" - placement="bottomRight" - > + <Dropdown :get-popup-container="getVxePopupContainer" placement="bottomRight"> <template #overlay> <Menu> - <MenuItem key="1" @click="handleUserInfo(row)"> - 鐢ㄦ埛淇℃伅 - </MenuItem> + <MenuItem key="1" @click="handleUserInfo(row)"> 鐢ㄦ埛淇℃伅 </MenuItem> <span v-access:code="['system:user:resetPwd']"> - <MenuItem key="2" @click="handleResetPwd(row)"> - 閲嶇疆瀵嗙爜 - </MenuItem> + <MenuItem key="2" @click="handleResetPwd(row)"> 閲嶇疆瀵嗙爜 </MenuItem> </span> </Menu> </template> diff --git a/eims-ui/packages/@core/base/shared/src/constants/dict-enum.ts b/eims-ui/packages/@core/base/shared/src/constants/dict-enum.ts index 5637ef2..2ceef3e 100644 --- a/eims-ui/packages/@core/base/shared/src/constants/dict-enum.ts +++ b/eims-ui/packages/@core/base/shared/src/constants/dict-enum.ts @@ -1,8 +1,10 @@ export enum DictEnum { + EIMS_EQU_UNIT = 'eims_equ_unit', // 璁惧鐩樼偣鐘舵�� EIMS_INVENTORY_DETAIL_STATU = 'inventory_detail_statu', // 璁惧鐩樼偣鐘舵�� EIMS_INVENTORY_STATU = 'inventory_statu', // 璁惧鐩樼偣鐘舵�� - REPAIR_REQ_STATUS = 'repair_req_status', // 鎶ヤ慨鐘舵�� + EQU_IMPORT_STATU = 'equ_import_status', // 璁惧瀵煎叆鐘舵�� REPAIR_FAULT_TYPE = 'repair_fault_type', // 鎶ヤ慨鐘舵�� + REPAIR_REQ_STATUS = 'repair_req_status', // 鎶ヤ慨鐘舵�� REPAIR_REQ_TYPE = 'repair_req_type', // 鎶ヤ慨绫诲瀷 REPAIR_URGENCY_LEVEL = 'repair_urgency_level', // 鎶ヤ慨绱ф�ョ▼搴� SYS_COMMON_STATUS = 'sys_common_status', diff --git a/eims-ui/packages/effects/request/src/request-client/request-client.ts b/eims-ui/packages/effects/request/src/request-client/request-client.ts index 6c84018..f1a008c 100644 --- a/eims-ui/packages/effects/request/src/request-client/request-client.ts +++ b/eims-ui/packages/effects/request/src/request-client/request-client.ts @@ -38,7 +38,7 @@ 'Content-Type': 'application/json;charset=utf-8', }, // 榛樿瓒呮椂鏃堕棿 - timeout: 10_000, + timeout: 30_000, }; const { ...axiosConfig } = options; const requestConfig = merge(axiosConfig, defaultConfig); diff --git a/eims/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/constant/CacheConstants.java b/eims/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/constant/CacheConstants.java index 0b2d7c2..b53c10d 100644 --- a/eims/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/constant/CacheConstants.java +++ b/eims/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/constant/CacheConstants.java @@ -33,4 +33,14 @@ */ String EIMS_GENERATE_CODE = "eims_generate_code:"; + /** + * ***********************瀛楀吀*********************** + */ + + + /** + * 璁惧鍗曚綅unit + */ + String EIMS_EQU_UNIT = "eims_equ_unit"; + } diff --git a/eims/ruoyi-modules/lb-eims/pom.xml b/eims/ruoyi-modules/lb-eims/pom.xml index 590b88e..e053d4f 100644 --- a/eims/ruoyi-modules/lb-eims/pom.xml +++ b/eims/ruoyi-modules/lb-eims/pom.xml @@ -97,6 +97,10 @@ <groupId>org.dromara</groupId> <artifactId>ruoyi-common-websocket</artifactId> </dependency> + <dependency> + <groupId>org.dromara</groupId> + <artifactId>ruoyi-system</artifactId> + </dependency> </dependencies> </project> diff --git a/eims/ruoyi-modules/lb-eims/src/main/java/org/dromara/eims/controller/EimsEquController.java b/eims/ruoyi-modules/lb-eims/src/main/java/org/dromara/eims/controller/EimsEquController.java index 2b9f0b0..0c81ee7 100644 --- a/eims/ruoyi-modules/lb-eims/src/main/java/org/dromara/eims/controller/EimsEquController.java +++ b/eims/ruoyi-modules/lb-eims/src/main/java/org/dromara/eims/controller/EimsEquController.java @@ -1,14 +1,19 @@ package org.dromara.eims.controller; +import java.util.ArrayList; import java.util.List; +import org.dromara.common.excel.core.ExcelResult; import org.dromara.eims.domain.bo.EimsEquBo; +import org.dromara.eims.domain.vo.EimsEquImportVo; import org.dromara.eims.domain.vo.EimsEquVo; +import org.dromara.eims.listener.EimsEquImportListener; import org.dromara.eims.service.IEimsEquService; import lombok.RequiredArgsConstructor; import jakarta.servlet.http.HttpServletResponse; import jakarta.validation.constraints.*; import cn.dev33.satoken.annotation.SaCheckPermission; +import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.*; import org.springframework.validation.annotation.Validated; import org.dromara.common.idempotent.annotation.RepeatSubmit; @@ -23,6 +28,7 @@ import org.dromara.common.mybatis.core.page.TableDataInfo; +import org.springframework.web.multipart.MultipartFile; /** * 銆愯澶囧彴璐︺�� @@ -104,4 +110,26 @@ @PathVariable Long[] equIds) { return toAjax(eimsEquipmentService.deleteWithValidByIds(List.of(equIds), true)); } + + /** + * 瀵煎叆鏁版嵁 + * + * @param file 瀵煎叆鏂囦欢 + * @param updateSupport 鏄惁鏇存柊宸插瓨鍦ㄦ暟鎹� + */ + @Log(title = "璁惧绠$悊", businessType = BusinessType.IMPORT) + @SaCheckPermission("eims:equ:import") + @PostMapping(value = "/importData", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) + public R<Void> importData(@RequestPart("file") MultipartFile file, boolean updateSupport) throws Exception { + ExcelResult<EimsEquImportVo> result = ExcelUtil.importExcel(file.getInputStream(), EimsEquImportVo.class, new EimsEquImportListener(updateSupport)); + return R.ok(result.getAnalysis()); + } + + /** + * 鑾峰彇瀵煎叆妯℃澘 + */ + @PostMapping("/importTemplate") + public void importTemplate(HttpServletResponse response) { + ExcelUtil.exportExcel(new ArrayList<>(), "璁惧鏁版嵁", EimsEquVo.class, response); + } } diff --git a/eims/ruoyi-modules/lb-eims/src/main/java/org/dromara/eims/domain/EimsEqu.java b/eims/ruoyi-modules/lb-eims/src/main/java/org/dromara/eims/domain/EimsEqu.java index a73057e..fc54040 100644 --- a/eims/ruoyi-modules/lb-eims/src/main/java/org/dromara/eims/domain/EimsEqu.java +++ b/eims/ruoyi-modules/lb-eims/src/main/java/org/dromara/eims/domain/EimsEqu.java @@ -1,5 +1,6 @@ package org.dromara.eims.domain; +import com.alibaba.excel.annotation.ExcelProperty; import com.fasterxml.jackson.annotation.JsonFormat; import org.dromara.common.mybatis.core.domain.BaseEntity; import com.baomidou.mybatisplus.annotation.*; @@ -147,5 +148,35 @@ */ private Long serviceLife; + /** + * 閿�鍞晢 + */ + private String seller; + + /** + * 鍗曚綅 + */ + private String unit; + + /** + * 缁忔墜浜� + */ + private Long handleUser; + + /** + * 閲囪喘浜� + */ + private Long purchaseUser; + + /** + * 闄勪欢 + */ + private String attachments; + + /** + * 璧勬枡 + */ + private String profile; + } diff --git a/eims/ruoyi-modules/lb-eims/src/main/java/org/dromara/eims/domain/bo/EimsEquBo.java b/eims/ruoyi-modules/lb-eims/src/main/java/org/dromara/eims/domain/bo/EimsEquBo.java index e77b87a..1bb5192 100644 --- a/eims/ruoyi-modules/lb-eims/src/main/java/org/dromara/eims/domain/bo/EimsEquBo.java +++ b/eims/ruoyi-modules/lb-eims/src/main/java/org/dromara/eims/domain/bo/EimsEquBo.java @@ -1,6 +1,7 @@ package org.dromara.eims.domain.bo; +import com.alibaba.excel.annotation.ExcelProperty; import com.fasterxml.jackson.annotation.JsonFormat; import org.dromara.eims.domain.EimsEqu; import io.github.linpeilie.annotations.AutoMapper; @@ -142,5 +143,41 @@ */ private Long serviceLife; + /** + * 閿�鍞晢 + */ + @ExcelProperty(value = "閿�鍞晢") + private String seller; + + /** + * 鍗曚綅 + */ + @ExcelProperty(value = "鍗曚綅") + private String unit; + + /** + * 缁忔墜浜� + */ + @ExcelProperty(value = "缁忔墜浜�") + private Long handleUser; + + /** + * 閲囪喘浜� + */ + @ExcelProperty(value = "閲囪喘浜�") + private Long purchaseUser; + + /** + * 闄勪欢 + */ + @ExcelProperty(value = "闄勪欢") + private String attachments; + + /** + * 璧勬枡 + */ + @ExcelProperty(value = "璧勬枡") + private String profile; + } diff --git a/eims/ruoyi-modules/lb-eims/src/main/java/org/dromara/eims/domain/vo/EimsEquImportVo.java b/eims/ruoyi-modules/lb-eims/src/main/java/org/dromara/eims/domain/vo/EimsEquImportVo.java new file mode 100644 index 0000000..753a07d --- /dev/null +++ b/eims/ruoyi-modules/lb-eims/src/main/java/org/dromara/eims/domain/vo/EimsEquImportVo.java @@ -0,0 +1,141 @@ +package org.dromara.eims.domain.vo; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.dromara.common.excel.annotation.ExcelDictFormat; +import org.dromara.common.excel.convert.ExcelDictConvert; + +import java.io.Serial; +import java.io.Serializable; +import java.util.Date; + +/** + * 璁惧瀵硅薄瀵煎叆VO + * + * @author zhuguifei + */ +@Data +@NoArgsConstructor +public class EimsEquImportVo implements Serializable { + @Serial + private static final long serialVersionUID = 1L; + /** + * + */ + private Long equId; + + /** + * 璁惧鍚嶇О + */ + @ExcelProperty(value = "璁惧鍚嶇О") + private String equName; + + /** + * 瑙勬牸鍨嬪彿 + */ + @ExcelProperty(value = "鍨嬪彿瑙勬牸") + private String modelNo; + + /** + * 鍒堕�犲巶瀹� + */ + @ExcelProperty(value = "鍒堕�犲巶瀹�") + private String madeIn; + + + /** + * 閿�鍞晢 + */ + @ExcelProperty(value = "閿�鍞晢") + private String seller; + + /** + * 鍗曚綅 + */ + @ExcelProperty(value = "鍗曚綅") + private String unit; + + /** + * 璧勪骇缂栧彿 + */ + @ExcelProperty(value = "璧勪骇缂栧彿") + private String assetNo; + + /** + * 鎵�鍦ㄥ満鎵� + */ + @ExcelProperty(value = "鎵�鍦ㄥ満鎵�") + private String location; + + /** + * 绠$悊鑰� + */ + @ExcelProperty(value = "绠$悊鑰�") + private String respPersonName; + + /** + * 璐拱鏃ユ湡 + */ + @ExcelProperty(value = "璐拱鏃ユ湡") + private String purchaseDateStr; + private Date purchaseDate; + + /** + * 瀹為檯楠屾敹鏃ユ湡 + */ + @ExcelProperty(value = "楠屾敹鏃ユ湡") + private String actualAcceptDateStr; + private Date actualAcceptDate; + + /** + * 缁忔墜浜� + */ + @ExcelProperty(value = "缁忔墜浜�") + private String handleUserName; + + /** + * 閲囪喘浜� + */ + @ExcelProperty(value = "閲囪喘浜�") + private String purchaseUserName; + + /** + * 棰濆畾鍔熺巼 + */ + @ExcelProperty(value = "鍔熺巼") + private String ratedPower; + + /** + * 鑱旂郴鐢佃瘽 + */ + @ExcelProperty(value = "鑱旂郴鐢佃瘽") + private String contactPhone; + + /** + * 浣跨敤鐘舵�� + */ + @ExcelProperty(value = "浣跨敤鐘舵��", converter = ExcelDictConvert.class) + @ExcelDictFormat(dictType = "sys_equ_status") + private String status; + + /** + * 澶囨敞 + */ + @ExcelProperty(value = "澶囨敞") + private String remark; + + /** + * 闄勪欢 + */ + @ExcelProperty(value = "闄勪欢") + private String attachments; + + /** + * 璧勬枡 + */ + @ExcelProperty(value = "璧勬枡") + private String profile; + +} diff --git a/eims/ruoyi-modules/lb-eims/src/main/java/org/dromara/eims/domain/vo/EimsEquVo.java b/eims/ruoyi-modules/lb-eims/src/main/java/org/dromara/eims/domain/vo/EimsEquVo.java index 5ba8cbb..36a3d0a 100644 --- a/eims/ruoyi-modules/lb-eims/src/main/java/org/dromara/eims/domain/vo/EimsEquVo.java +++ b/eims/ruoyi-modules/lb-eims/src/main/java/org/dromara/eims/domain/vo/EimsEquVo.java @@ -1,9 +1,12 @@ package org.dromara.eims.domain.vo; import java.util.Date; + import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.annotation.write.style.ColumnWidth; import com.fasterxml.jackson.annotation.JsonFormat; +import org.dromara.common.mybatis.core.domain.BaseEntity; import org.dromara.common.translation.annotation.Translation; import org.dromara.common.translation.constant.TransConstant; import org.dromara.eims.domain.EimsEqu; @@ -25,7 +28,7 @@ @Data @ExcelIgnoreUnannotated @AutoMapper(target = EimsEqu.class) -public class EimsEquVo implements Serializable { +public class EimsEquVo extends BaseEntity implements Serializable { @Serial private static final long serialVersionUID = 1L; @@ -33,12 +36,124 @@ /** * */ - @ExcelProperty(value = "") private Long equId; + + /** + * 璁惧鍚嶇О + */ + @ExcelProperty(value = "璁惧鍚嶇О") + private String equName; + + /** + * 瑙勬牸鍨嬪彿 + */ + @ExcelProperty(value = "瑙勬牸鍨嬪彿") + private String modelNo; + + /** + * 鍒堕�犲巶瀹� + */ + @ExcelProperty(value = "鍒堕�犲巶瀹�") + private String madeIn; + + + /** + * 閿�鍞晢 + */ + @ExcelProperty(value = "閿�鍞晢") + private String seller; + + /** + * 鍗曚綅 + */ + @ExcelProperty(value = "鍗曚綅") + private String unit; + + /** + * 璧勪骇缂栧彿 + */ + @ExcelProperty(value = "璧勪骇缂栧彿") + private String assetNo; + + /** + * 鎵�鍦ㄥ満鎵� + */ + @ExcelProperty(value = "鎵�鍦ㄥ満鎵�") + private String location; + + /** + * 绠$悊鑰� + */ + @Translation(type = TransConstant.USER_ID_TO_NICKNAME, mapper = "respPerson") + @ExcelProperty(value = "绠$悊鑰�") + private String respPersonName; + + /** + * 璐拱鏃ユ湡 + */ + @ExcelProperty(value = "璐拱鏃ユ湡") + @ColumnWidth(24) + @JsonFormat(pattern = "yyyy-MM-dd") + private Date purchaseDate; + + /** + * 瀹為檯楠屾敹鏃ユ湡 + */ + @ExcelProperty(value = "楠屾敹鏃ユ湡") + @ColumnWidth(24) + @JsonFormat(pattern = "yyyy-MM-dd") + private Date actualAcceptDate; + + /** + * 缁忔墜浜� + */ + @Translation(type = TransConstant.USER_ID_TO_NICKNAME, mapper = "handleUser") + @ExcelProperty(value = "缁忔墜浜�") + private String handleUserName; + + /** + * 閲囪喘浜� + */ + @Translation(type = TransConstant.USER_ID_TO_NICKNAME, mapper = "purchaseUser") + @ExcelProperty(value = "閲囪喘浜�") + private String purchaseUserName; + + /** + * 棰濆畾鍔熺巼 + */ + @ExcelProperty(value = "鍔熺巼") + private String ratedPower; + + /** + * 鑱旂郴鐢佃瘽 + */ + @ExcelProperty(value = "鑱旂郴鐢佃瘽") + private String contactPhone; + + /** + * 浣跨敤鐘舵�� + */ + @ExcelProperty(value = "浣跨敤鐘舵��", converter = ExcelDictConvert.class) + @ExcelDictFormat(dictType = "sys_equ_status") + private String status; + + /** + * 澶囨敞 + */ + @ExcelProperty(value = "澶囨敞") + private String remark; + + /** + * 闄勪欢 + */ + @ExcelProperty(value = "闄勪欢") + private String attachments; + + /** * 璁惧缂栫爜 */ - @ExcelProperty(value = "璁惧缂栫爜") + //@ExcelProperty(value = "璁惧缂栫爜") private String equCode; @@ -50,71 +165,21 @@ /** * 璁惧绫诲瀷鍚嶇О */ - @ExcelProperty(value = "璁惧绫诲瀷") + //@ExcelProperty(value = "璁惧绫诲瀷") @Translation(type = TransConstant.EQU_YPE_ID_TO_NAME, mapper = "equTypeId") private String equTypeName; - /** - * 璧勪骇缂栧彿 - */ - @ExcelProperty(value = "璧勪骇缂栧彿") - private String assetNo; - - /** - * 璁惧鍚嶇О - - */ - @ExcelProperty(value = "璁惧鍚嶇О") - private String equName; - - /** - * 鍨嬪彿 - */ - @ExcelProperty(value = "鍨嬪彿") - private String modelNo; - - /** - * 鍒堕�犲晢 - */ - @ExcelProperty(value = "鍒堕�犲晢") - private String madeIn; - - /** - * 棰濆害鍔熺巼 - */ - @ExcelProperty(value = "棰濆害鍔熺巼") - private String ratedPower; /** * 閾墝淇℃伅 */ - @ExcelProperty(value = "閾墝淇℃伅") + //@ExcelProperty(value = "閾墝淇℃伅") private String plateInfo; - - /** - * 閲囪喘鏃ユ湡 - */ - @ExcelProperty(value = "閲囪喘鏃ユ湡") - @JsonFormat(pattern = "yyyy-MM-dd") - private Date purchaseDate; - - /** - * 鐘舵�� - */ - @ExcelProperty(value = "鐘舵��", converter = ExcelDictConvert.class) - @ExcelDictFormat(dictType = "sys_equ_status") - private String status; - - /** - * 鎵�鍦ㄥ満鎵� - */ - @ExcelProperty(value = "鎵�鍦ㄥ満鎵�") - private String location; /** * 浣跨敤閮ㄩ棬锛堝叧鑱攊d锛� */ - @ExcelProperty(value = "浣跨敤閮ㄩ棬", converter = ExcelDictConvert.class) + //@ExcelProperty(value = "浣跨敤閮ㄩ棬", converter = ExcelDictConvert.class) @ExcelDictFormat(readConverterExp = "鍏�=鑱攊d") private Long deptUsed; /** @@ -126,75 +191,77 @@ /** * 璐d换浜�(鍏宠仈id) */ - @ExcelProperty(value = "璐d换浜�(鍏宠仈id)") + //@ExcelProperty(value = "璐d换浜�(鍏宠仈id)") private Long respPerson; - /** - * 閮ㄩ棬鍚� - */ - @Translation(type = TransConstant.USER_ID_TO_NICKNAME, mapper = "respPerson") - private String respPersonName; - - /** - * 鑱旂郴鐢佃瘽 - */ - @ExcelProperty(value = "鑱旂郴鐢佃瘽") - private String contactPhone; /** * 姝e紡浣跨敤鏃ユ湡 */ - @ExcelProperty(value = "姝e紡浣跨敤鏃ユ湡") + //@ExcelProperty(value = "姝e紡浣跨敤鏃ユ湡") @JsonFormat(pattern = "yyyy-MM-dd") private Date deployDate; /** * 寮�濮嬭瘯鐢ㄦ棩鏈� */ - @ExcelProperty(value = "寮�濮嬭瘯鐢ㄦ棩鏈�") + //@ExcelProperty(value = "寮�濮嬭瘯鐢ㄦ棩鏈�") @JsonFormat(pattern = "yyyy-MM-dd") private Date trialDate; /** * 璁″垝楠屾敹鏃ユ湡 */ - @ExcelProperty(value = "璁″垝楠屾敹鏃ユ湡") + //@ExcelProperty(value = "璁″垝楠屾敹鏃ユ湡") @JsonFormat(pattern = "yyyy-MM-dd") private Date planAcceptDate; /** - * 瀹為檯楠屾敹鏃ユ湡 - */ - @ExcelProperty(value = "瀹為檯楠屾敹鏃ユ湡") - @JsonFormat(pattern = "yyyy-MM-dd") - private Date actualAcceptDate; - - /** * 瀵煎叆鐘舵�侊紙瀛楀吀锛� */ - @ExcelProperty(value = "瀵煎叆鐘舵��", converter = ExcelDictConvert.class) + //@ExcelProperty(value = "瀵煎叆鐘舵��", converter = ExcelDictConvert.class) @ExcelDictFormat(readConverterExp = "瀛�=鍏�") private String importStatus; - /** * 鐩樼偣鏍囧織 */ - @ExcelProperty(value = "鐩樼偣鏍囧織") + //@ExcelProperty(value = "鐩樼偣鏍囧織") private String inventoryFlag; /** * 涓婃鐩樼偣鏃ユ湡 */ - @ExcelProperty(value = "涓婃鐩樼偣鏃ユ湡") + //@ExcelProperty(value = "涓婃鐩樼偣鏃ユ湡") @JsonFormat(pattern = "yyyy-MM-dd") private Date inventoryDate; /** * 浣跨敤骞撮檺 */ - @ExcelProperty(value = "浣跨敤骞撮檺") + //@ExcelProperty(value = "浣跨敤骞撮檺") private Long serviceLife; + /** + * 缁忔墜浜� + */ + //@ExcelProperty(value = "缁忔墜浜�") + private Long handleUser; + + /** + * 閲囪喘浜� + */ + //@ExcelProperty(value = "閲囪喘浜�") + private Long purchaseUser; + + /** + * 璧勬枡 + */ + @ExcelProperty(value = "璧勬枡") + private String profile; + + + + } diff --git a/eims/ruoyi-modules/lb-eims/src/main/java/org/dromara/eims/listener/EimsEquImportListener.java b/eims/ruoyi-modules/lb-eims/src/main/java/org/dromara/eims/listener/EimsEquImportListener.java new file mode 100644 index 0000000..2d62524 --- /dev/null +++ b/eims/ruoyi-modules/lb-eims/src/main/java/org/dromara/eims/listener/EimsEquImportListener.java @@ -0,0 +1,181 @@ +package org.dromara.eims.listener; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.util.ObjectUtil; +import com.alibaba.excel.context.AnalysisContext; +import com.alibaba.excel.event.AnalysisEventListener; +import com.alibaba.excel.exception.ExcelDataConvertException; +import org.dromara.common.core.constant.CacheConstants; +import org.dromara.common.core.constant.Constants; +import org.dromara.common.core.exception.ServiceException; +import org.dromara.common.core.service.DictService; +import org.dromara.common.core.utils.DateUtils; +import org.dromara.common.core.utils.SpringUtils; +import org.dromara.common.core.utils.StringUtils; +import org.dromara.common.excel.core.ExcelListener; +import org.dromara.common.excel.core.ExcelResult; +import org.dromara.common.satoken.utils.LoginHelper; +import lombok.extern.slf4j.Slf4j; +import org.dromara.eims.domain.bo.EimsEquBo; +import org.dromara.eims.domain.vo.EimsEquImportVo; +import org.dromara.eims.domain.vo.EimsEquVo; +import org.dromara.eims.service.IEimsEquService; +import org.dromara.system.domain.bo.SysUserBo; +import org.dromara.system.service.ISysUserService; + +import java.util.List; +import java.util.Map; + +/** + * 璁惧鑷畾涔夊鍏� + * + * @author zhuguifei + */ +@Slf4j +public class EimsEquImportListener extends AnalysisEventListener<EimsEquImportVo> implements ExcelListener<EimsEquImportVo> { + + private final IEimsEquService equService; + + private final ISysUserService userService; + + private final DictService dictService; + // 褰撳墠瀵煎叆鐢ㄦ埛 + private final Long operUserId; + + private final Boolean isUpdateSupport; + + //unit瀛楀吀 + private final Map<String, String> unitDictMap; + + + private int successNum = 0; + private int failureNum = 0; + private final StringBuilder successMsg = new StringBuilder(); + private final StringBuilder failureMsg = new StringBuilder(); + + public EimsEquImportListener(Boolean isUpdateSupport) { + this.equService = SpringUtils.getBean(IEimsEquService.class); + ; + this.userService = SpringUtils.getBean(ISysUserService.class); + this.dictService = SpringUtils.getBean(DictService.class); + this.isUpdateSupport = isUpdateSupport; + this.operUserId = LoginHelper.getUserId(); + this.unitDictMap = dictService.getAllDictByDictType(CacheConstants.EIMS_EQU_UNIT); + } + + @Override + public void invoke(EimsEquImportVo equVo, AnalysisContext context) { + try { + // 鏍规嵁璧勪骇缂栧彿鏌ヨ璁惧鏄惁宸插瓨鍦� + EimsEquVo eimsEquVo = equService.queryByAssetNo(equVo.getAssetNo()); + // 澶勭悊涓嶈鍒欐暟鎹� + //1.鍗曚綅unit-excel瀵煎叆鏁版嵁涓崟浣嶅瓧娈典笉瑙勫垯锛岀壒娈婂鐞� + normalizeUnit(equVo, unitDictMap); + //2.璐拱鏃ユ湡銆侀獙鏀舵棩鏈� 鐗规畩澶勭悊 + if (StringUtils.isNotEmpty(equVo.getPurchaseDateStr())) { + try { + equVo.setPurchaseDate(DateUtils.parseDate(equVo.getPurchaseDateStr())); + } catch (Exception e) { + e.printStackTrace(); + } + } + if (StringUtils.isNotEmpty(equVo.getActualAcceptDateStr())) { + try { + equVo.setActualAcceptDate(DateUtils.parseDate(equVo.getActualAcceptDateStr())); + } catch (Exception e) { + e.printStackTrace(); + } + } + + // 楠岃瘉鏄惁瀛樺湪杩欎釜鐢ㄦ埛 + if (ObjectUtil.isNull(eimsEquVo)) { + EimsEquBo equ = BeanUtil.toBean(equVo, EimsEquBo.class); + // TODO 鏍¢獙 + //ValidatorUtils.validate(equ); + equ.setCreateBy(operUserId); + equService.insertByBo(equ); + successNum++; + successMsg.append("<br/>").append(successNum).append("銆佽澶� ").append(equ.getEquName()).append(" 瀵煎叆鎴愬姛"); + } else if (isUpdateSupport) { + // TODO 鎵ц瑕嗙洊閫昏緫 + //successNum++; + //successMsg.append("<br/>").append(successNum).append("銆佽澶� ").append(equ.getEquName()).append(" 鏇存柊鎴愬姛"); + } else { + failureNum++; + failureMsg.append("<br/>").append(failureNum).append("銆佽澶� ").append(eimsEquVo.getEquName()).append(eimsEquVo.getAssetNo()).append(" 宸插瓨鍦�"); + } + } catch (Exception e) { + failureNum++; + String msg = "<br/>" + failureNum + "銆佽澶� " + equVo.getEquName() + " 瀵煎叆澶辫触锛�"; + failureMsg.append(msg).append(e.getMessage()); + log.error(msg, e); + } + } + + @Override + public void doAfterAllAnalysed(AnalysisContext context) { + + } + + @Override + public ExcelResult<EimsEquImportVo> getExcelResult() { + return new ExcelResult<>() { + + @Override + public String getAnalysis() { + if (failureNum > 0) { + failureMsg.insert(0, "寰堟姳姝夛紝瀵煎叆澶辫触锛佸叡 " + failureNum + " 鏉℃暟鎹牸寮忎笉姝g‘锛岄敊璇涓嬶細"); + throw new ServiceException(failureMsg.toString()); + } else { + successMsg.insert(0, "鎭枩鎮紝鏁版嵁宸插叏閮ㄥ鍏ユ垚鍔燂紒鍏� " + successNum + " 鏉★紝鏁版嵁濡備笅锛�"); + } + return successMsg.toString(); + } + + @Override + public List<EimsEquImportVo> getList() { + return null; + } + + @Override + public List<String> getErrorList() { + return null; + } + }; + } + + @Override + public void onException(Exception exception, AnalysisContext context) throws Exception { + log.error("瑙f瀽澶辫触锛屼絾鏄户缁В鏋愪笅涓�琛�:{}", exception.getMessage()); + // 濡傛灉鏄煇涓�涓崟鍏冩牸鐨勮浆鎹㈠紓甯� 鑳借幏鍙栧埌鍏蜂綋琛屽彿 + // 濡傛灉瑕佽幏鍙栧ご鐨勪俊鎭� 閰嶅悎invokeHeadMap浣跨敤 + if (exception instanceof ExcelDataConvertException) { + ExcelDataConvertException excelDataConvertException = (ExcelDataConvertException) exception; + log.error("绗瑊}琛岋紝绗瑊}鍒楄В鏋愬紓甯革紝鏁版嵁涓�:{}", excelDataConvertException.getRowIndex(), + excelDataConvertException.getColumnIndex(), excelDataConvertException.getCellData()); + } + } + + + /** + * 涓哄鍏ヨ澶囧尮閰嶅崟浣� + * + * @param equVo + * @param unitDictMap + */ + private void normalizeUnit(EimsEquImportVo equVo, Map<String, String> unitDictMap) { + if (equVo == null || StringUtils.isEmpty(equVo.getUnit()) || unitDictMap == null || unitDictMap.isEmpty()) { + return; + } + String originalUnit = equVo.getUnit(); + //閬垮厤閿欒鍗曚綅 + equVo.setUnit(null); + for (Map.Entry<String, String> entry : unitDictMap.entrySet()) { + if (originalUnit.contains(entry.getValue())) { + equVo.setUnit(entry.getValue()); + break; + } + } + } + +} diff --git a/eims/ruoyi-modules/lb-eims/src/main/java/org/dromara/eims/service/IEimsEquService.java b/eims/ruoyi-modules/lb-eims/src/main/java/org/dromara/eims/service/IEimsEquService.java index 6d5da2a..976e854 100644 --- a/eims/ruoyi-modules/lb-eims/src/main/java/org/dromara/eims/service/IEimsEquService.java +++ b/eims/ruoyi-modules/lb-eims/src/main/java/org/dromara/eims/service/IEimsEquService.java @@ -26,6 +26,14 @@ EimsEquVo queryById(Long equId); /** + * 鏌ヨ銆愯澶囧彴璐︺�� + * + * @param assetNo 璧勪骇缂栧彿 + * @return 銆愯澶囧彴璐︺�� + */ + EimsEquVo queryByAssetNo(String assetNo); + + /** * 鍒嗛〉鏌ヨ銆愯澶囧彴璐︺�戝垪琛� * * @param bo 鏌ヨ鏉′欢 diff --git a/eims/ruoyi-modules/lb-eims/src/main/java/org/dromara/eims/service/impl/EimsEquServiceImpl.java b/eims/ruoyi-modules/lb-eims/src/main/java/org/dromara/eims/service/impl/EimsEquServiceImpl.java index 5ddfc59..5c4ace9 100644 --- a/eims/ruoyi-modules/lb-eims/src/main/java/org/dromara/eims/service/impl/EimsEquServiceImpl.java +++ b/eims/ruoyi-modules/lb-eims/src/main/java/org/dromara/eims/service/impl/EimsEquServiceImpl.java @@ -46,8 +46,15 @@ * @return 銆愯澶囧彴璐︺�� */ @Override - public EimsEquVo queryById(Long equId){ + public EimsEquVo queryById(Long equId) { return baseMapper.selectVoById(equId); + } + + @Override + public EimsEquVo queryByAssetNo(String assetNo) { + LambdaQueryWrapper<EimsEqu> lqw = new LambdaQueryWrapper<>(); + lqw.eq(EimsEqu::getAssetNo, assetNo); + return baseMapper.selectVoOne(lqw); } /** @@ -87,7 +94,7 @@ */ if (equTypeId != null && equTypeId > 0) { List<Long> allDescendantIds = getAllDescendantIds(equTypeId); - lqw.in(EimsEqu::getEquTypeId,allDescendantIds); + lqw.in(EimsEqu::getEquTypeId, allDescendantIds); } lqw.like(StringUtils.isNotBlank(bo.getEquName()), EimsEqu::getEquName, bo.getEquName()); @@ -117,6 +124,7 @@ /** * 鏍规嵁id锛岃幏鍙栨墍鏈夊悗浠d + * * @param rootId * @return */ @@ -140,6 +148,7 @@ } } } + /** * 鏂板銆愯澶囧彴璐︺�� * @@ -173,7 +182,7 @@ /** * 淇濆瓨鍓嶇殑鏁版嵁鏍¢獙 */ - private void validEntityBeforeSave(EimsEqu entity){ + private void validEntityBeforeSave(EimsEqu entity) { //TODO 鍋氫竴浜涙暟鎹牎楠�,濡傚敮涓�绾︽潫 } @@ -186,7 +195,7 @@ */ @Override public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) { - if(isValid){ + if (isValid) { //TODO 鍋氫竴浜涗笟鍔′笂鐨勬牎楠�,鍒ゆ柇鏄惁闇�瑕佹牎楠� } return baseMapper.deleteByIds(ids) > 0; diff --git a/eims/ruoyi-modules/lb-eims/src/main/java/org/dromara/eims/service/impl/EimsRepairReqServiceImpl.java b/eims/ruoyi-modules/lb-eims/src/main/java/org/dromara/eims/service/impl/EimsRepairReqServiceImpl.java index 42fa842..6ef4ace 100644 --- a/eims/ruoyi-modules/lb-eims/src/main/java/org/dromara/eims/service/impl/EimsRepairReqServiceImpl.java +++ b/eims/ruoyi-modules/lb-eims/src/main/java/org/dromara/eims/service/impl/EimsRepairReqServiceImpl.java @@ -68,19 +68,21 @@ private QueryWrapper<EimsRepairReq> buildWrapper(EimsRepairReqBo bo) { Map<String, Object> params = bo.getParams(); QueryWrapper<EimsRepairReq> qw = Wrappers.query(); - qw.eq(StringUtils.isNotBlank(bo.getCode()),"code", bo.getCode()); - qw.eq(StringUtils.isNotBlank(bo.getStatus()), "status", bo.getStatus()); - qw.eq(bo.getReqTime() != null, "req_time", bo.getReqTime()); - qw.eq(bo.getReqDept() != null, "req_dept", bo.getReqDept()); - qw.eq(bo.getReqUser() != null,"req_user", bo.getReqUser()); - qw.eq(StringUtils.isNotBlank(bo.getUrgencyLevel()), "urgency_level", bo.getUrgencyLevel()); - qw.eq(StringUtils.isNotBlank(bo.getReqType()), "req_type", bo.getReqType()); - qw.eq(bo.getEquId() != null, "equ_id", bo.getEquId()); - qw.eq(bo.getRepairDept() != null,"repair_dept", bo.getRepairDept()); - qw.eq(bo.getRepairUser() != null, "repair_user", bo.getRepairUser()); - qw.eq(StringUtils.isNotBlank(bo.getFaultType()), "fault_type", bo.getFaultType()); + qw.like(StringUtils.isNotBlank(bo.getCode()),"a.code", bo.getCode()); + qw.eq(StringUtils.isNotBlank(bo.getStatus()), "a.status", bo.getStatus()); + qw.eq(bo.getReqTime() != null, "a.req_time", bo.getReqTime()); + qw.eq(bo.getReqDept() != null, "a.req_dept", bo.getReqDept()); + qw.eq(bo.getReqUser() != null,"a.req_user", bo.getReqUser()); + qw.eq(StringUtils.isNotBlank(bo.getUrgencyLevel()), "a.urgency_level", bo.getUrgencyLevel()); + qw.eq(StringUtils.isNotBlank(bo.getReqType()), "a.req_type", bo.getReqType()); + qw.eq(bo.getEquId() != null, "a.equ_id", bo.getEquId()); + qw.eq(bo.getRepairDept() != null,"a.repair_dept", bo.getRepairDept()); + qw.eq(bo.getRepairUser() != null, "a.repair_user", bo.getRepairUser()); + qw.eq(StringUtils.isNotBlank(bo.getFaultType()), "a,fault_type", bo.getFaultType()); + qw.eq(params.containsKey("createBy"), "a.create_by", params.get("createBy")); + qw.eq(params.containsKey("status"), "a.status", params.get("status")); qw.between(params.get("beginReqTime") != null && params.get("endReqTime") != null, - "req_time", params.get("beginReqTime"), params.get("endReqTime")); + "a.req_time", params.get("beginReqTime"), params.get("endReqTime")); return qw; } -- Gitblit v1.9.3