From d465f6537bda4c5b3844a15b73badf704f44c9a1 Mon Sep 17 00:00:00 2001 From: zhangherong <571457620@qq.com> Date: 星期一, 07 四月 2025 16:01:16 +0800 Subject: [PATCH] art: 设备管理-用户选择-根据岗位选择用户 --- lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamWeekMaintenanceOrderServiceImpl.java | 107 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 107 insertions(+), 0 deletions(-) diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamWeekMaintenanceOrderServiceImpl.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamWeekMaintenanceOrderServiceImpl.java index d220660..b8e533c 100644 --- a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamWeekMaintenanceOrderServiceImpl.java +++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamWeekMaintenanceOrderServiceImpl.java @@ -1,12 +1,23 @@ package org.jeecg.modules.eam.service.impl; import cn.hutool.core.collection.CollectionUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.apache.commons.lang3.StringUtils; +import org.apache.shiro.SecurityUtils; import org.jeecg.common.constant.CommonConstant; +import org.jeecg.common.constant.DataBaseConstant; +import org.jeecg.common.exception.JeecgBootException; +import org.jeecg.common.system.vo.LoginUser; +import org.jeecg.common.util.oConvertUtils; import org.jeecg.modules.eam.constant.MaintenanceStatusEnum; import org.jeecg.modules.eam.constant.OrderCreationMethodEnum; import org.jeecg.modules.eam.entity.EamWeekMaintenanceOrder; +import org.jeecg.modules.eam.entity.EamWeekMaintenanceOrderDetail; import org.jeecg.modules.eam.mapper.EamWeekMaintenanceOrderMapper; +import org.jeecg.modules.eam.request.EamWeekMaintenanceQuery; import org.jeecg.modules.eam.request.EamWeekMaintenanceRequest; import org.jeecg.modules.eam.service.IEamWeekMaintenanceOrderDetailService; import org.jeecg.modules.eam.service.IEamWeekMaintenanceOrderService; @@ -15,6 +26,10 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; /** * @Description: 鍛ㄤ繚宸ュ崟 @@ -57,4 +72,96 @@ } return true; } + + @Override + public IPage<EamWeekMaintenanceOrder> queryPageList(Page<EamWeekMaintenanceOrder> page, EamWeekMaintenanceQuery query) { + QueryWrapper<EamWeekMaintenanceOrder> queryWrapper = new QueryWrapper<>(); + //鐢ㄦ埛鏁版嵁鏉冮檺 + LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); + if (sysUser == null) { + return page; + } + if (StringUtils.isNotBlank(sysUser.getEquipmentIds())) { + //閫夋嫨浜嗚澶囷紝鏍规嵁璁惧id杩囨护璁惧 + List<String> equipArr = Arrays.asList(sysUser.getEquipmentIds().split(",")); + queryWrapper.in("e.equipment_code", equipArr); + } else { + //娌℃湁閫夋嫨璁惧锛屾牴鎹溅闂磋繃婊よ澶� + queryWrapper.exists("select 1 from mdc_user_production t where t.user_id={0} and t.pro_id=e.org_id ", sysUser.getId()); + } + //鏌ヨ鏉′欢杩囨护 + if (query != null) { + if (StringUtils.isNotBlank(query.getEquipmentId())) { + queryWrapper.eq("wmo.equipment_id", query.getEquipmentId()); + } + if (StringUtils.isNotBlank(query.getOrderNum())) { + queryWrapper.like("wmo.order_num", query.getOrderNum()); + } + if (StringUtils.isNotBlank(query.getMaintenanceStatus())) { + queryWrapper.eq("wmo.maintenance_status", query.getMaintenanceStatus()); + } + if (query.getMaintenanceDateBegin() != null && query.getMaintenanceDateEnd() != null) { + queryWrapper.between("wmo.maintenance_date", query.getMaintenanceDateBegin(), query.getMaintenanceDateEnd()); + } + //鎺掑簭 + if (StringUtils.isNotBlank(query.getColumn()) && StringUtils.isNotBlank(query.getOrder())) { + String column = query.getColumn(); + if (column.endsWith(CommonConstant.DICT_TEXT_SUFFIX)) { + column = column.substring(0, column.lastIndexOf(CommonConstant.DICT_TEXT_SUFFIX)); + } + if (DataBaseConstant.SQL_ASC.equalsIgnoreCase(query.getOrder())) { + queryWrapper.orderByAsc("wmo." + oConvertUtils.camelToUnderline(column)); + } else { + queryWrapper.orderByDesc("wmo." + oConvertUtils.camelToUnderline(column)); + } + } else { + queryWrapper.orderByDesc("wmo.create_time"); + } + } else { + queryWrapper.orderByDesc("wmo.create_time"); + } + + return eamWeekMaintenanceOrderMapper.queryPageList(page, queryWrapper); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public boolean editWeekMaintenance(EamWeekMaintenanceRequest request) { + EamWeekMaintenanceOrder entity = eamWeekMaintenanceOrderMapper.selectById(request.getId()); + if(entity == null){ + throw new JeecgBootException("缂栬緫鐨勬暟鎹凡鍒犻櫎锛岃鍒锋柊閲嶈瘯锛�"); + } + if(!MaintenanceStatusEnum.WAIT_MAINTENANCE.name().equals(entity.getMaintenanceStatus())){ + throw new JeecgBootException("鍙湁寰呬繚鍏荤姸鎬佺殑鏁版嵁鎵嶅彲缂栬緫锛�"); + } + entity.setMaintenanceDate(request.getMaintenanceDate()); + entity.setOperator(request.getOperator()); + entity.setRemark(request.getRemark()); + + eamWeekMaintenanceOrderMapper.updateById(entity); + //澶勭悊璇︽儏 + if(CollectionUtil.isNotEmpty(request.getTableDetailList())) { + List<EamWeekMaintenanceOrderDetail> addList = new ArrayList<>(); + List<EamWeekMaintenanceOrderDetail> updateList = new ArrayList<>(); + request.getTableDetailList().forEach(tableDetail -> { + tableDetail.setOrderId(entity.getId()); + if(tableDetail.getId() == null){ + addList.add(tableDetail); + }else { + updateList.add(tableDetail); + } + }); + if(CollectionUtil.isNotEmpty(addList)){ + eamWeekMaintenanceOrderDetailService.saveBatch(addList); + } + if(CollectionUtil.isNotEmpty(updateList)){ + eamWeekMaintenanceOrderDetailService.updateBatchById(updateList); + } + } + if(CollectionUtil.isNotEmpty(request.getRemoveDetailList())) { + List<String> ids = request.getRemoveDetailList().stream().map(EamWeekMaintenanceOrderDetail::getId).collect(Collectors.toList()); + eamWeekMaintenanceOrderDetailService.removeBatchByIds(ids); + } + return true; + } } -- Gitblit v1.9.3