| | |
| | | enum Api { |
| | | inspRecordExport = '/eims/inspRecord/export', |
| | | inspRecordList = '/eims/inspRecord/list', |
| | | inspStRecordList = '/eims/inspRecord/stList', |
| | | root = '/eims/inspRecord' |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | /** |
| | | * 查询汇总下的点检记录列表 |
| | | * @param query |
| | | * @returns {*} |
| | | */ |
| | | |
| | | export function listInspStRecord(params?: any) { |
| | | return requestClient.get<InspectRecordVO[]>(Api.inspStRecordList, { params }); |
| | | } |
| | | |
| | | /** |
| | | * 查询点检记录详细 |
| | | * @param inspRecordId |
| | | */ |
| | |
| | | Object.assign(formValues, params); |
| | | } else { |
| | | // 未传参则查询一个不存在的值 |
| | | const params = { [keyName]: -1 }; |
| | | Object.assign(formValues, params); |
| | | // const params = { [keyName]: -1 }; |
| | | // Object.assign(formValues, params); |
| | | return false |
| | | } |
| | | return await props.listApi({ |
| | | pageNum: page.currentPage, |
| | |
| | | fixed: 'left' |
| | | }, |
| | | { |
| | | title: '保养年月', |
| | | field: 'planTime', |
| | | minWidth: 120 |
| | | title: '保养时间', |
| | | field: 'planTimeStr', |
| | | minWidth: 200 |
| | | }, |
| | | { |
| | | title: '状态', |
| | |
| | | minWidth: 80, |
| | | slots: { |
| | | default: ({ row }) => { |
| | | if (!row.status) return ''; |
| | | return renderDict(row.status, DictEnum.EIMS_INSPECT_STATUS); |
| | | } |
| | | } |
| | |
| | | <script setup lang="ts"> |
| | | import type { Recordable } from '@vben/types'; |
| | | |
| | | import { onMounted, ref } from 'vue'; |
| | | |
| | | import { Page, useVbenDrawer, type VbenFormProps } from '@vben/common-ui'; |
| | | import { $t } from '@vben/locales'; |
| | | import { addFullName, getPopupContainer, getVxePopupContainer } from '@vben/utils'; |
| | | |
| | | import { Modal, Popconfirm, Space } from 'ant-design-vue'; |
| | | import { Button, Modal, Popconfirm, Space } from 'ant-design-vue'; |
| | | |
| | | import { useVbenVxeGrid, vxeCheckboxChecked, type VxeGridProps, vxeSortEvent } from '#/adapter/vxe-table'; |
| | | import { delMaintOrder, listMaintOrderGroupDetail } from '#/api/eims/maint-order'; |
| | | import { listInspStRecord } from '#/api/eims/insp-record'; |
| | | import { delInspectSt, listInspectSt } from '#/api/eims/insp-st'; |
| | | import { getDeptTree, userList } from '#/api/system/user'; |
| | | import BasisSubTable from '#/views/eims/components/basis-sub-table.vue'; |
| | |
| | | |
| | | import { columns, querySchema } from './data'; |
| | | import inspStDrawer from './insp-st-drawer.vue'; |
| | | import type { Recordable } from '@vben/types'; |
| | | import { $t } from '@vben/locales'; |
| | | |
| | | defineExpose({ |
| | | tableSelect |
| | | }); |
| | | |
| | | /** |
| | | * 视图模式 |
| | | * day-根据日汇总 |
| | | * month-根据月汇总 |
| | | */ |
| | | enum ViewMode { |
| | | Day = 'Day', |
| | | Month = 'Month' |
| | | } |
| | | |
| | | const curViewMode = ref<ViewMode>(ViewMode.Month); |
| | | const formOptions: VbenFormProps = { |
| | | commonConfig: { |
| | | labelWidth: 80, |
| | |
| | | collapsed: true, |
| | | schema: querySchema(), |
| | | wrapperClass: 'grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4', |
| | | handleReset: async () => { |
| | | // eslint-disable-next-line no-use-before-define |
| | | const { formApi, reload } = tableApi; |
| | | await formApi.resetForm(); |
| | | const formValues = formApi.form.values; |
| | | formApi.setLatestSubmissionValues(formValues); |
| | | await reload(formValues); |
| | | }, |
| | | // 日期选择格式化 |
| | | fieldMappingTime: [['planTime', ['params[beginPlanTime]', 'params[endPlanTime]'], ['YYYY-MM-DD 00:00:00', 'YYYY-MM-DD 23:59:59']]] |
| | | }; |
| | |
| | | proxyConfig: { |
| | | ajax: { |
| | | query: async ({ page }, formValues = {}) => { |
| | | const params = { 'viewMode': curViewMode.value }; |
| | | Object.assign(formValues, params); |
| | | return await listInspectSt({ |
| | | pageNum: page.currentPage, |
| | | pageSize: page.pageSize, |
| | |
| | | }, |
| | | id: 'insp-st-index' |
| | | }; |
| | | const fieldsToExclude = new Set(['action', 'inspTime', 'maintUserNames', 'specialNote', 'status']); |
| | | const gridOptions2: VxeGridProps = { |
| | | checkboxConfig: { |
| | | // 高亮 |
| | | highlight: true, |
| | | // 翻页时保留选中状态 |
| | | reserve: true |
| | | // 点击行选中 |
| | | // trigger: 'row' |
| | | }, |
| | | columns: columns?.filter((column: any) => !fieldsToExclude.has(column?.field)), |
| | | height: 'auto', |
| | | keepSource: true, |
| | | pagerConfig: {}, |
| | | proxyConfig: { |
| | | ajax: { |
| | | query: async ({ page }, formValues = {}) => { |
| | | const params = { 'viewMode': curViewMode.value }; |
| | | Object.assign(formValues, params); |
| | | return await listInspectSt({ |
| | | pageNum: page.currentPage, |
| | | pageSize: page.pageSize, |
| | | ...formValues |
| | | }); |
| | | } |
| | | } |
| | | }, |
| | | rowConfig: { |
| | | isHover: true, |
| | | keyField: 'id' |
| | | }, |
| | | sortConfig: { |
| | | // 远程排序 |
| | | remote: true, |
| | | // 支持多字段排序 默认关闭 |
| | | multiple: true |
| | | }, |
| | | id: 'insp-st-index' |
| | | }; |
| | | |
| | | const recordId = ref<string>(); |
| | | const [BasicTable, tableApi] = useVbenVxeGrid({ |
| | | formOptions, |
| | |
| | | sortChange: (sortParams) => vxeSortEvent(tableApi, sortParams), |
| | | cellClick: (e: any) => { |
| | | const { row } = e; |
| | | recordId.value = `${row.equId}_${row.planTime}`; |
| | | recordId.value = `${row.equId}_${row.planTime}_${curViewMode.value}`; |
| | | } |
| | | } |
| | | }); |
| | |
| | | } |
| | | ]); |
| | | } |
| | | |
| | | const [InspStDrawer, inspStDrawerApi] = useVbenDrawer({ |
| | | connectedComponent: inspStDrawer |
| | | }); |
| | | |
| | | |
| | | async function handleEdit(record: Recordable<any>) { |
| | | inspStDrawerApi.setData({ id: record.id }); |
| | | inspStDrawerApi.open(); |
| | | } |
| | | |
| | | async function handleDelete(row: Recordable<any>) { |
| | | await delInspectSt(row.id); |
| | | await tableApi.query(); |
| | |
| | | function tableSelect() { |
| | | return tableApi.grid.getCheckboxRecords(); |
| | | } |
| | | |
| | | const dayBtn = ref<any>('default'); |
| | | const monBtn = ref<any>('primary'); |
| | | |
| | | function queryData(type: ViewMode) { |
| | | if (type === ViewMode.Day) { |
| | | dayBtn.value = 'primary'; |
| | | monBtn.value = 'default'; |
| | | curViewMode.value = ViewMode.Day; |
| | | tableApi.setGridOptions(gridOptions2); |
| | | } else if (type === ViewMode.Month) { |
| | | dayBtn.value = 'default'; |
| | | monBtn.value = 'primary'; |
| | | curViewMode.value = ViewMode.Month; |
| | | tableApi.setGridOptions(gridOptions); |
| | | } |
| | | tableApi.query(); |
| | | } |
| | | </script> |
| | | |
| | | <template> |
| | |
| | | <div class="flex h-full gap-[8px] flex-col"> |
| | | <BasicTable class="h-2/3" table-title="点检记录列表"> |
| | | <template #toolbar-tools> |
| | | <Space > |
| | | <Space> |
| | | <Button :type="dayBtn" @click.stop="queryData(ViewMode.Day)">日视图</Button> |
| | | <Button :type="monBtn" @click.stop="queryData(ViewMode.Month)">月视图</Button> |
| | | <a-button |
| | | :disabled="!vxeCheckboxChecked(tableApi)" |
| | | danger |
| | |
| | | </Popconfirm> |
| | | </Space> |
| | | </template> |
| | | |
| | | </BasicTable> |
| | | <BasisSubTable |
| | | :columns="recordCol" |
| | | :list-api="listMaintOrderGroupDetail" |
| | | :req-value="recordId" |
| | | class="h-1/3" |
| | | req-key="maintCode" |
| | | title="保养实施项目" |
| | | /> |
| | | <BasisSubTable :columns="recordCol" :list-api="listInspStRecord" :req-value="recordId" class="h-1/3" |
| | | req-key="inspCode" title="点检记录" /> |
| | | </div> |
| | | <InspStDrawer @reload="tableApi.query()" /> |
| | | </Page> |
| | |
| | | package org.dromara.eims.controller; |
| | | |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.ZoneId; |
| | | import java.time.temporal.TemporalAdjusters; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import lombok.RequiredArgsConstructor; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import jakarta.validation.constraints.*; |
| | | import cn.dev33.satoken.annotation.SaCheckPermission; |
| | | import org.dromara.common.core.utils.DateUtils; |
| | | import org.dromara.common.core.utils.StringUtils; |
| | | import org.dromara.eims.domain.bo.EimsMaintOrderBo; |
| | | import org.dromara.eims.domain.vo.EimsMaintOrderVo; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.dromara.common.idempotent.annotation.RepeatSubmit; |
| | |
| | | return eimsInspectRecordService.queryPageListCustom(bo, pageQuery); |
| | | } |
| | | |
| | | @SaCheckPermission("eims:inspectRecord:list") |
| | | @GetMapping("/stList") |
| | | public TableDataInfo<EimsInspectRecordVo> groupDetail(EimsInspectRecordBo bo, PageQuery pageQuery) { |
| | | // 这里使用inspCode传递了 equid + plantime + viewModel(day-日视图 month-月视图) |
| | | String inspCode = bo.getInspCode(); |
| | | if (StringUtils.isEmpty(inspCode) || !inspCode.contains("_")) { |
| | | return TableDataInfo.build(new Page<>(0,0)); |
| | | } |
| | | String[] split = inspCode.split("_"); |
| | | bo.setEquId(Long.valueOf(split[0])); |
| | | bo.setInspCode(null); |
| | | LocalDate planTime = DateUtils.parseDate(split[1]).toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); |
| | | if((split[2].equals("Day"))){ |
| | | LocalDateTime startOfDay = planTime.atStartOfDay(); |
| | | LocalDateTime endOfDay = planTime.plusDays(1).atStartOfDay().minusSeconds(1); |
| | | Map<String, Object> params = bo.getParams(); |
| | | params.put("beginPlanTime",startOfDay); |
| | | params.put("endPlanTime",endOfDay); |
| | | }else if((split[2].equals("Month"))){ |
| | | LocalDate startOfMonth = planTime.with(TemporalAdjusters.firstDayOfMonth()); |
| | | LocalDate endOfMonth = planTime.with(TemporalAdjusters.lastDayOfMonth()); |
| | | Map<String, Object> params = bo.getParams(); |
| | | params.put("beginPlanTime",startOfMonth); |
| | | params.put("endPlanTime",endOfMonth); |
| | | } |
| | | return eimsInspectRecordService.queryPageListCustom(bo, pageQuery); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 导出点检记录列表 |
| | | */ |
| | |
| | | */ |
| | | private String remark; |
| | | |
| | | //前端界面查看模式 day-日视图 month-月视图 |
| | | private String viewMode; |
| | | |
| | | |
| | | |
| | | |
| | |
| | | */ |
| | | @ExcelProperty(value = "计划时间") |
| | | private Date planTime; |
| | | private String planTimeStr; |
| | | |
| | | /** |
| | | * 状态 |
| | |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; |
| | | import org.dromara.eims.domain.EimsInspectRecord; |
| | | import org.dromara.eims.domain.EimsInspectSt; |
| | | import org.dromara.eims.domain.vo.EimsInspectRecordVo; |
| | | import org.dromara.eims.domain.vo.EimsInspectStVo; |
| | | |
| | | /** |
| | | * 点检记录Mapper接口 |
| | |
| | | */ |
| | | public interface EimsInspectRecordMapper extends BaseMapperPlus<EimsInspectRecord, EimsInspectRecordVo> { |
| | | Page<EimsInspectRecordVo> selectInspRecordList(@Param("page") Page<EimsInspectRecordVo> page, @Param(Constants.WRAPPER) Wrapper<EimsInspectRecord> queryWrapper); |
| | | Page<EimsInspectStVo> selectInspRecordDayList(@Param("page") Page<EimsInspectStVo> page, @Param(Constants.WRAPPER) Wrapper<EimsInspectSt> queryWrapper); |
| | | |
| | | } |
| | |
| | | package org.dromara.eims.service; |
| | | |
| | | import org.dromara.eims.domain.bo.EimsInspectStBo; |
| | | import org.dromara.eims.domain.vo.EimsInspectRecordVo; |
| | | import org.dromara.eims.domain.bo.EimsInspectRecordBo; |
| | | import org.dromara.common.mybatis.core.page.TableDataInfo; |
| | | import org.dromara.common.mybatis.core.page.PageQuery; |
| | | import org.dromara.eims.domain.vo.EimsInspectStVo; |
| | | |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | |
| | | * @return 点检记录分页列表 |
| | | */ |
| | | TableDataInfo<EimsInspectRecordVo> queryPageListCustom(EimsInspectRecordBo bo, PageQuery pageQuery); |
| | | |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.dromara.eims.domain.EimsInspectPlan; |
| | | import org.dromara.eims.domain.EimsInspectSt; |
| | | import org.dromara.eims.domain.EimsMaintPlan; |
| | | import org.dromara.eims.domain.bo.EimsInspectStBo; |
| | | import org.dromara.eims.domain.vo.EimsInspectStVo; |
| | | import org.dromara.eims.domain.vo.EimsMaintOrderVo; |
| | | import org.dromara.eims.mapper.EimsInspectPlanMapper; |
| | | import org.dromara.eims.mapper.EimsMaintPlanMapper; |
| | |
| | | return TableDataInfo.build(page); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 查询符合条件的点检记录列表 |
| | | * |
| | |
| | | qw.in(bo.getInspDept() != null, "ir.insp_dept", getAllDescendantIds(bo.getInspDept())); |
| | | qw.eq(bo.getStatus() != null, "ir.status", bo.getStatus()); |
| | | qw.eq(bo.getInspResult() != null, "ir.insp_result", bo.getInspResult()); |
| | | qw.between(params.get("beginPlanTime") != null && params.get("endPlanTime") != null, |
| | | "ir.plan_time", params.get("beginPlanTime"), params.get("endPlanTime")); |
| | | qw.eq(bo.getPlanTime()!=null, |
| | | "ir.plan_time", bo.getPlanTime()); |
| | | qw.orderByDesc("ir.create_time"); |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 根据id,获取所有后代id |
| | | * |
| | |
| | | import java.time.LocalDate; |
| | | import java.time.ZoneId; |
| | | import java.time.temporal.TemporalAdjusters; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Collection; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public TableDataInfo<EimsInspectStVo> queryPageList(EimsInspectStBo bo, PageQuery pageQuery) { |
| | | QueryWrapper<EimsInspectSt> lqw = buildWrapper(bo); |
| | | Page<EimsInspectStVo> result = baseMapper.selectInspStList(pageQuery.build(), lqw); |
| | | // 填充数据 |
| | | fillStData(result); |
| | | return TableDataInfo.build(result); |
| | | // 月视图 |
| | | if(bo.getViewMode().equals("Month")){ |
| | | QueryWrapper<EimsInspectSt> qw = buildWrapper(bo); |
| | | Page<EimsInspectStVo> result = baseMapper.selectInspStList(pageQuery.build(), qw); |
| | | // 填充数据 |
| | | fillStData(result); |
| | | return TableDataInfo.build(result); |
| | | // 日视图 |
| | | }else if(bo.getViewMode().equals("Day")){ |
| | | Page<EimsInspectStVo> result = recordMapper.selectInspRecordDayList(pageQuery.build(), buildGroupWrapper(bo)); |
| | | return TableDataInfo.build(result); |
| | | } |
| | | |
| | | return null; |
| | | } |
| | | |
| | | private void fillStData(Page<EimsInspectStVo> result) { |
| | |
| | | |
| | | } |
| | | |
| | | private QueryWrapper<EimsInspectSt> buildGroupWrapper(EimsInspectStBo bo) { |
| | | Map<String, Object> params = bo.getParams(); |
| | | QueryWrapper<EimsInspectSt> qw = Wrappers.query(); |
| | | qw.like(StringUtils.isNotBlank(bo.getTitle()), "CONCAT(DATE_FORMAT(ir.plan_time, '%Y%m%d'), equ.equ_name)", bo.getTitle()); |
| | | qw.like(StringUtils.isNotBlank(bo.getEquName()), "equ.equ_name", bo.getEquName()); |
| | | qw.like(StringUtils.isNotBlank(bo.getAssetNo()), "equ.asset_no", bo.getAssetNo()); |
| | | qw.between(params.get("beginPlanTime") != null && params.get("endPlanTime") != null, |
| | | "ir.plan_time", params.get("beginPlanTime"), params.get("endPlanTime")); |
| | | qw.eq(bo.getInspUser() != null, "ir.insp_user", bo.getInspUser()); |
| | | qw.eq(bo.getVerifyUser() != null, "ir.verify_user", bo.getVerifyUser()); |
| | | qw.eq(bo.getStatus() != null, "ir.status", bo.getStatus()); |
| | | qw.between(params.get("beginPlanTime") != null && params.get("endPlanTime") != null, |
| | | "ir.plan_time", params.get("beginPlanTime"), params.get("endPlanTime")); |
| | | qw.groupBy(Arrays.asList("ir.equ_id","ir.plan_time")); |
| | | qw.orderByDesc( "ir.plan_time"); |
| | | |
| | | return qw; |
| | | } |
| | | |
| | | /** |
| | | * 查询符合条件的点检汇总列表 |
| | | * |
| | |
| | | |
| | | <resultMap type="org.dromara.eims.domain.vo.EimsInspectRecordVo" id="EimsInspRecordVoResult"> |
| | | </resultMap> |
| | | |
| | | <resultMap type="org.dromara.eims.domain.vo.EimsInspectStVo" id="EimsInspectStVoResult"> |
| | | </resultMap> |
| | | |
| | | <select id="selectInspRecordList" resultMap="EimsInspRecordVoResult"> |
| | | SELECT ir.*,equ.equ_name equName,equ.equ_code equCode,equ.asset_no assetNo,equ.model_no modelNo,ir.create_time createTime, |
| | | us.nick_name inspUserName,dp.dept_name inspDeptName,ue.nick_name verifyUserName |
| | |
| | | ${ew.getCustomSqlSegment} |
| | | </select> |
| | | |
| | | |
| | | <select id="selectInspRecordDayList" resultMap="EimsInspectStVoResult"> |
| | | SELECT |
| | | MAX(ir.id) id, |
| | | ir.equ_id, |
| | | ir.plan_time, |
| | | DATE_FORMAT(ir.plan_time, '%Y-%m-%d') as planTimeStr, |
| | | CONCAT(DATE_FORMAT(ir.plan_time, '%Y%m%d'), equ.equ_name) as title, |
| | | MAX(equ.equ_name) AS equName, |
| | | MAX(equ.equ_code) AS equCode, |
| | | MAX(equ.asset_no) AS assetNo, |
| | | MAX(equ.model_no) AS modelNo, |
| | | GROUP_CONCAT(us.nick_name SEPARATOR ', ') AS inspUserNames, |
| | | GROUP_CONCAT(ue.nick_name SEPARATOR ', ') AS verifyUserNames, |
| | | COUNT(ir.id) AS recordCount, -- 一天点检总数 |
| | | SUM(CASE WHEN ir.status = 0 THEN 1 ELSE 0 END) AS unCheckCount, |
| | | SUM(CASE WHEN ir.status = 1 THEN 1 ELSE 0 END) AS checkCount, |
| | | SUM(CASE WHEN ir.insp_result = 1 THEN 1 ELSE 0 END) AS normalNum, |
| | | SUM(CASE WHEN ir.insp_result = 2 THEN 1 ELSE 0 END) AS abNormalNum |
| | | FROM eims_inspect_record ir |
| | | LEFT JOIN eims_equ equ ON ir.equ_id = equ.equ_id |
| | | LEFT JOIN sys_user us ON ir.insp_user = us.user_id |
| | | LEFT JOIN sys_user ue ON ir.verify_user = ue.user_id |
| | | LEFT JOIN sys_dept dp ON ir.insp_dept = dp.dept_id |
| | | ${ew.getCustomSqlSegment} |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | <resultMap type="org.dromara.eims.domain.vo.EimsInspectStVo" id="MaintInspStVoResult"> |
| | | </resultMap> |
| | | <select id="selectInspStList" resultMap="MaintInspStVoResult"> |
| | | SELECT st.*,equ.equ_name equName,equ.asset_no assetNo FROM eims_inspect_st st |
| | | SELECT st.*,equ.equ_name equName,equ.asset_no assetNo, DATE_FORMAT(st.plan_time, '%Y-%m') as planTimeStr FROM eims_inspect_st st |
| | | LEFT JOIN eims_equ equ on st.equ_id = equ.equ_id |
| | | ${ew.getCustomSqlSegment} |
| | | </select> |
| | | |
| | | |
| | | </mapper> |