Browse Source

pms 保养计划列表 根据设备名称 设备编码 模糊搜索

zhangcl 1 tuần trước cách đây
mục cha
commit
f8f1aa9f5c

+ 12 - 3
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/maintenance/vo/IotMaintenancePlanPageReqVO.java

@@ -1,10 +1,12 @@
 package cn.iocoder.yudao.module.pms.controller.admin.maintenance.vo;
 package cn.iocoder.yudao.module.pms.controller.admin.maintenance.vo;
 
 
-import lombok.*;
-import java.util.*;
-import io.swagger.v3.oas.annotations.media.Schema;
 import cn.iocoder.yudao.framework.common.pojo.PageParam;
 import cn.iocoder.yudao.framework.common.pojo.PageParam;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
 import org.springframework.format.annotation.DateTimeFormat;
 import org.springframework.format.annotation.DateTimeFormat;
+
 import java.time.LocalDateTime;
 import java.time.LocalDateTime;
 
 
 import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
 import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@@ -40,4 +42,11 @@ public class IotMaintenancePlanPageReqVO extends PageParam {
     @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
     @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
     private LocalDateTime[] createTime;
     private LocalDateTime[] createTime;
 
 
+    /**
+     * 扩展字段
+     */
+    @Schema(description = "设备名称 模糊搜索", example = "钻机")
+    private String deviceName;
+    @Schema(description = "设备编码 模糊搜索", example = "YF620")
+    private String deviceCode;
 }
 }

+ 37 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/mysql/IotDeviceMapper.java

@@ -1,5 +1,6 @@
 package cn.iocoder.yudao.module.pms.dal.mysql;
 package cn.iocoder.yudao.module.pms.dal.mysql;
 
 
+import cn.hutool.core.util.StrUtil;
 import cn.iocoder.yudao.framework.common.pojo.PageResult;
 import cn.iocoder.yudao.framework.common.pojo.PageResult;
 import cn.iocoder.yudao.framework.common.pojo.SortablePageParam;
 import cn.iocoder.yudao.framework.common.pojo.SortablePageParam;
 import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
 import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
@@ -105,6 +106,42 @@ public interface IotDeviceMapper extends BaseMapperX<IotDeviceDO> {
                 .eqIfPresent(IotDeviceDO::getBomSyncStatus, reqVO.getBomSyncStatus()));
                 .eqIfPresent(IotDeviceDO::getBomSyncStatus, reqVO.getBomSyncStatus()));
     }
     }
 
 
+    default List<IotDeviceDO> selectListAlone(IotDevicePageReqVO reqVO) {
+        LambdaQueryWrapperX<IotDeviceDO> queryWrapper = new LambdaQueryWrapperX<>();
+        queryWrapper
+                .inIfPresent(IotDeviceDO::getDeptId, reqVO.getDeviceIds())
+                .eqIfPresent(IotDeviceDO::getBrand, reqVO.getBrand())
+                .eqIfPresent(IotDeviceDO::getModel, reqVO.getModel())
+                .eqIfPresent(IotDeviceDO::getDeviceStatus, reqVO.getDeviceStatus())
+                .eqIfPresent(IotDeviceDO::getAssetProperty, reqVO.getAssetProperty())
+                .eqIfPresent(IotDeviceDO::getPicUrl, reqVO.getPicUrl())
+                .eqIfPresent(IotDeviceDO::getRemark, reqVO.getRemark())
+                .eqIfPresent(IotDeviceDO::getManufacturerId, reqVO.getManufacturerId())
+                .eqIfPresent(IotDeviceDO::getSupplierId, reqVO.getSupplierId())
+                .eqIfPresent(IotDeviceDO::getNameplate, reqVO.getNameplate())
+                .eqIfPresent(IotDeviceDO::getExpires, reqVO.getExpires())
+                .eqIfPresent(IotDeviceDO::getPlPrice, reqVO.getPlPrice())
+                .eqIfPresent(IotDeviceDO::getPlYear, reqVO.getPlYear())
+                .betweenIfPresent(IotDeviceDO::getPlStartDate, reqVO.getPlStartDate())
+                .eqIfPresent(IotDeviceDO::getPlMonthed, reqVO.getPlMonthed())
+                .eqIfPresent(IotDeviceDO::getPlAmounted, reqVO.getPlAmounted())
+                .eqIfPresent(IotDeviceDO::getRemainAmount, reqVO.getRemainAmount())
+                .eqIfPresent(IotDeviceDO::getInfoId, reqVO.getInfoId())
+                .eqIfPresent(IotDeviceDO::getInfoType, reqVO.getInfoType())
+                .eqIfPresent(IotDeviceDO::getAssetClass, reqVO.getAssetClass())
+                .likeIfPresent(IotDeviceDO::getInfoName, reqVO.getInfoName())
+                .eqIfPresent(IotDeviceDO::getInfoRemark, reqVO.getInfoRemark())
+                .eqIfPresent(IotDeviceDO::getInfoUrl, reqVO.getInfoUrl())
+                .eqIfPresent(IotDeviceDO::getTemplateJson, reqVO.getTemplateJson())
+                .eqIfPresent(IotDeviceDO::getBomSyncStatus, reqVO.getBomSyncStatus());
+        if (StrUtil.isNotBlank(reqVO.getDeviceName())) {
+            queryWrapper.and(i -> i.like(IotDeviceDO::getDeviceName, reqVO.getDeviceName())
+                    .or()
+                    .like(IotDeviceDO::getDeviceCode, reqVO.getDeviceName()));
+        }
+        return selectList(queryWrapper);
+    }
+
     default List<IotDeviceDO> selectDataCollect() {
     default List<IotDeviceDO> selectDataCollect() {
         return selectList(new LambdaQueryWrapperX<IotDeviceDO>()
         return selectList(new LambdaQueryWrapperX<IotDeviceDO>()
                 .isNotNull(IotDeviceDO::getYfDeviceId));
                 .isNotNull(IotDeviceDO::getYfDeviceId));

+ 5 - 3
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/mysql/maintenance/IotMaintenancePlanMapper.java

@@ -14,21 +14,23 @@ import java.util.List;
 /**
 /**
  * 保养计划 Mapper
  * 保养计划 Mapper
  *
  *
- * @author 芋道源码
+ * @author ruiqi
  */
  */
 @Mapper
 @Mapper
 public interface IotMaintenancePlanMapper extends BaseMapperX<IotMaintenancePlanDO> {
 public interface IotMaintenancePlanMapper extends BaseMapperX<IotMaintenancePlanDO> {
 
 
-    default PageResult<IotMaintenancePlanDO> selectPage(IotMaintenancePlanPageReqVO reqVO, Collection<Long> ids) {
+    default PageResult<IotMaintenancePlanDO> selectPage(IotMaintenancePlanPageReqVO reqVO,
+                                                        Collection<Long> ids, Collection<Long> planIds) {
         return selectPage(reqVO, new LambdaQueryWrapperX<IotMaintenancePlanDO>()
         return selectPage(reqVO, new LambdaQueryWrapperX<IotMaintenancePlanDO>()
                 .eqIfPresent(IotMaintenancePlanDO::getSerialNumber, reqVO.getSerialNumber())
                 .eqIfPresent(IotMaintenancePlanDO::getSerialNumber, reqVO.getSerialNumber())
-                .likeIfPresent(IotMaintenancePlanDO::getName, reqVO.getName())
+                // .likeIfPresent(IotMaintenancePlanDO::getName, reqVO.getName())
                 .eqIfPresent(IotMaintenancePlanDO::getResponsiblePerson, reqVO.getResponsiblePerson())
                 .eqIfPresent(IotMaintenancePlanDO::getResponsiblePerson, reqVO.getResponsiblePerson())
                 .likeIfPresent(IotMaintenancePlanDO::getResponsiblePersonName, reqVO.getResponsiblePersonName())
                 .likeIfPresent(IotMaintenancePlanDO::getResponsiblePersonName, reqVO.getResponsiblePersonName())
                 .eqIfPresent(IotMaintenancePlanDO::getRemark, reqVO.getRemark())
                 .eqIfPresent(IotMaintenancePlanDO::getRemark, reqVO.getRemark())
                 .eqIfPresent(IotMaintenancePlanDO::getStatus, reqVO.getStatus())
                 .eqIfPresent(IotMaintenancePlanDO::getStatus, reqVO.getStatus())
                 .betweenIfPresent(IotMaintenancePlanDO::getCreateTime, reqVO.getCreateTime())
                 .betweenIfPresent(IotMaintenancePlanDO::getCreateTime, reqVO.getCreateTime())
                 .inIfPresent(IotMaintenancePlanDO::getDeptId, ids)
                 .inIfPresent(IotMaintenancePlanDO::getDeptId, ids)
+                .inIfPresent(IotMaintenancePlanDO::getId, planIds)
                 .orderByDesc(IotMaintenancePlanDO::getId));
                 .orderByDesc(IotMaintenancePlanDO::getId));
     }
     }
 
 

+ 35 - 1
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/maintenance/IotMaintenancePlanServiceImpl.java

@@ -1,15 +1,21 @@
 package cn.iocoder.yudao.module.pms.service.maintenance;
 package cn.iocoder.yudao.module.pms.service.maintenance;
 
 
+import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.core.util.StrUtil;
 import cn.iocoder.yudao.framework.common.pojo.PageResult;
 import cn.iocoder.yudao.framework.common.pojo.PageResult;
 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
+import cn.iocoder.yudao.module.pms.controller.admin.iotmaintenancebom.vo.IotMaintenanceBomPageReqVO;
 import cn.iocoder.yudao.module.pms.controller.admin.iotmaintenancebom.vo.IotMaintenanceBomSaveReqVO;
 import cn.iocoder.yudao.module.pms.controller.admin.iotmaintenancebom.vo.IotMaintenanceBomSaveReqVO;
 import cn.iocoder.yudao.module.pms.controller.admin.iotmaintenancebom.vo.IotTobeMaintenanceBomRespVO;
 import cn.iocoder.yudao.module.pms.controller.admin.iotmaintenancebom.vo.IotTobeMaintenanceBomRespVO;
 import cn.iocoder.yudao.module.pms.controller.admin.maintenance.vo.IotMaintenancePlanPageReqVO;
 import cn.iocoder.yudao.module.pms.controller.admin.maintenance.vo.IotMaintenancePlanPageReqVO;
 import cn.iocoder.yudao.module.pms.controller.admin.maintenance.vo.IotMaintenancePlanSaveReqVO;
 import cn.iocoder.yudao.module.pms.controller.admin.maintenance.vo.IotMaintenancePlanSaveReqVO;
 import cn.iocoder.yudao.module.pms.controller.admin.maintenance.vo.IotMaintenanceSaveVO;
 import cn.iocoder.yudao.module.pms.controller.admin.maintenance.vo.IotMaintenanceSaveVO;
+import cn.iocoder.yudao.module.pms.controller.admin.vo.IotDevicePageReqVO;
+import cn.iocoder.yudao.module.pms.dal.dataobject.IotDeviceDO;
 import cn.iocoder.yudao.module.pms.dal.dataobject.iotmaintenancebom.IotMaintenanceBomDO;
 import cn.iocoder.yudao.module.pms.dal.dataobject.iotmaintenancebom.IotMaintenanceBomDO;
 import cn.iocoder.yudao.module.pms.dal.dataobject.maintenance.IotMaintenancePlanDO;
 import cn.iocoder.yudao.module.pms.dal.dataobject.maintenance.IotMaintenancePlanDO;
+import cn.iocoder.yudao.module.pms.dal.mysql.IotDeviceMapper;
 import cn.iocoder.yudao.module.pms.dal.mysql.iotmaintenancebom.IotMaintenanceBomMapper;
 import cn.iocoder.yudao.module.pms.dal.mysql.iotmaintenancebom.IotMaintenanceBomMapper;
 import cn.iocoder.yudao.module.pms.dal.mysql.maintenance.IotMaintenancePlanMapper;
 import cn.iocoder.yudao.module.pms.dal.mysql.maintenance.IotMaintenancePlanMapper;
 import cn.iocoder.yudao.module.pms.dal.redis.BizNoRedisDAO;
 import cn.iocoder.yudao.module.pms.dal.redis.BizNoRedisDAO;
@@ -43,6 +49,8 @@ public class IotMaintenancePlanServiceImpl implements IotMaintenancePlanService
     private BizNoRedisDAO bizNoRedisDAO;
     private BizNoRedisDAO bizNoRedisDAO;
     @Resource
     @Resource
     private DeptService deptService;
     private DeptService deptService;
+    @Resource
+    private IotDeviceMapper iotDeviceMapper;
 
 
     @Override
     @Override
     @Transactional(rollbackFor = Exception.class)
     @Transactional(rollbackFor = Exception.class)
@@ -114,7 +122,33 @@ public class IotMaintenancePlanServiceImpl implements IotMaintenancePlanService
             ids = deptService.getChildDeptIdListFromCache(pageReqVO.getDeptId());
             ids = deptService.getChildDeptIdListFromCache(pageReqVO.getDeptId());
             ids.add(pageReqVO.getDeptId());
             ids.add(pageReqVO.getDeptId());
         }
         }
-        return iotMaintenancePlanMapper.selectPage(pageReqVO, ids);
+        if (StrUtil.isNotBlank(pageReqVO.getName())) {
+            pageReqVO.setDeviceName(pageReqVO.getName());
+            pageReqVO.setDeviceCode(pageReqVO.getName());
+        }
+        // 设备名称模糊搜索 查询保养计划明细
+        IotDevicePageReqVO reqVO = new IotDevicePageReqVO();
+        reqVO.setDeviceName(pageReqVO.getDeviceName());
+        List<IotDeviceDO> devices = iotDeviceMapper.selectListAlone(reqVO);
+        Set<Long> deviceIds = new HashSet<>();
+        if (CollUtil.isNotEmpty(devices)) {
+            devices.forEach(device -> {
+                deviceIds.add(device.getId());
+            });
+        }
+        // 根据设备id查询保养计划明细
+        Set<Long> planIds = new HashSet<>();
+        if (CollUtil.isNotEmpty(deviceIds)) {
+            IotMaintenanceBomPageReqVO planBomReqVO = new IotMaintenanceBomPageReqVO();
+            planBomReqVO.setDeviceIds(new ArrayList<>(deviceIds));
+            List<IotMaintenanceBomDO> planBoms = iotMaintenanceBomMapper.selectList(planBomReqVO);
+            if (CollUtil.isNotEmpty(planBoms)) {
+                planBoms.forEach(bom -> {
+                    planIds.add(bom.getPlanId());
+                });
+            }
+        }
+        return iotMaintenancePlanMapper.selectPage(pageReqVO, ids, planIds);
     }
     }
 
 
     @Override
     @Override