Browse Source

巡检计划调整,工单查询条件app

lipenghui 1 month ago
parent
commit
c5c2f48477

+ 19 - 23
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/IotDeviceController.java

@@ -269,10 +269,6 @@ public class IotDeviceController {
     @PreAuthorize("@ss.hasPermission('rq:iot-device:query')")
     public CommonResult<PageResult<IotDeviceRespVO>> getIotDeviceTdPage(@Valid IotDevicePageReqVO pageReqVO) {
         List<String> codes = new ArrayList<>();
-//        List<YfDeviceDO> allDevice = yfDeviceService.getAllDevice();
-//        allDevice.forEach(d -> {
-//            codes.add(d.getSerialNumber());
-//        });
         PageResult<IotDeviceDO> pageResult = iotDeviceService.getIotDeviceTdPage(pageReqVO, codes);
         if (CollUtil.isEmpty(pageResult.getList())) {
             return success(new PageResult<>(pageResult.getTotal()));
@@ -285,30 +281,30 @@ public class IotDeviceController {
             IotProductClassifyDO iotProductClassify = iotProductClassifyService.getIotProductClassify(iotDeviceRespVO.getAssetClass());
             iotDeviceRespVO.setAssetClassName(iotProductClassify.getName());
         }
-//        for (IotDeviceRespVO iotDeviceRespVO : result.getList()) {
-//            IotProductClassifyDO iotProductClassify = iotProductClassifyService.getIotProductClassify(iotDeviceRespVO.getAssetClass());
-//            iotDeviceRespVO.setAssetClassName(iotProductClassify.getName());
-//            String deviceCode = iotDeviceRespVO.getDeviceCode();
-//            allDevice.stream().filter(e -> e.getSerialNumber().equals(deviceCode)).findFirst().ifPresent(e -> {
-//                iotDeviceRespVO.setIfInline(e.getStatus());
-//                Integer i = deviceMapper.tableIfExist(e.getSerialNumber().toLowerCase());
-//                if (i==1) {
-//                    List<DeviceVO> deviceVOS = deviceMapper.selectLastTime(e.getSerialNumber());
-//                    if (CollUtil.isNotEmpty(deviceVOS)) {
-//                        Timestamp ts = deviceVOS.get(0).getTs();
-//                        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-//                        String format = sdf.format(ts);
-//                        iotDeviceRespVO.setLastInlineTime(format);
-//                    }
-//                }
-//            });
-//
-//        }
 
         return success(result);
     }
 
+    @GetMapping("/td/page/app")
+    @Operation(summary = "获得设备台账包含数采信息")
+    @PreAuthorize("@ss.hasPermission('rq:iot-device:query')")
+    public CommonResult<PageResult<IotDeviceRespVO>> getIotDeviceTdPageApp(@Valid IotDevicePageReqVO pageReqVO) {
+        List<String> codes = new ArrayList<>();
+        PageResult<IotDeviceDO> pageResult = iotDeviceService.getIotDeviceTdPageApp(pageReqVO, codes);
+        if (CollUtil.isEmpty(pageResult.getList())) {
+            return success(new PageResult<>(pageResult.getTotal()));
+        }
+        Map<Long, DeptDO> deptMap = deptService.getDeptMap(
+                convertList(pageResult.getList(), IotDeviceDO::getDeptId));
+        PageResult<IotDeviceRespVO> result = new PageResult<>(IotDeviceConvert.INSTANCE.convertList(pageResult.getList(), deptMap),
+                pageResult.getTotal());
+        for (IotDeviceRespVO iotDeviceRespVO : result.getList()) {
+            IotProductClassifyDO iotProductClassify = iotProductClassifyService.getIotProductClassify(iotDeviceRespVO.getAssetClass());
+            iotDeviceRespVO.setAssetClassName(iotProductClassify.getName());
+        }
 
+        return success(result);
+    }
 
 
     @GetMapping("/td/test")

+ 1 - 1
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/stat/IotStaticController.java

@@ -107,7 +107,7 @@ public class IotStaticController {
 
     @GetMapping("/notice")
     @PermitAll
-    public CommonResult<PageResult<OrderVo>> getNotice(@Valid OrderVo pageReqVO) {
+    public CommonResult<PageResult<OrderVo>> getNotice(@Valid @RequestBody OrderVo pageReqVO) {
         PageResult<OrderVo> notice = iotMaintainService.getNotice(pageReqVO);
         if (CollUtil.isEmpty(notice.getList())) {
             return success(new PageResult<>(notice.getTotal()));

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

@@ -152,6 +152,18 @@ public interface IotDeviceMapper extends BaseMapperX<IotDeviceDO> {
                 .orderByAsc(IotDeviceDO::getIfInline).orderByDesc(IotDeviceDO::getLastInlineTime));
     }
 
+
+    default PageResult<IotDeviceDO> selectTdPageApp(IotDevicePageReqVO reqVO, Collection<Long> deptIds) {
+        LambdaQueryWrapper<IotDeviceDO> wrapper = new LambdaQueryWrapper<>();
+        wrapper.like(StringUtils.isNotBlank(reqVO.getCommonParam()), IotDeviceDO::getDeviceName, reqVO.getCommonParam())
+                .or()
+                .like(StringUtils.isNotBlank(reqVO.getCommonParam()), IotDeviceDO::getDeviceCode, reqVO.getCommonParam())
+                .or()
+                .like(StringUtils.isNotBlank(reqVO.getCommonParam()), IotDeviceDO::getChargeName, reqVO.getCommonParam()).orderByDesc(IotDeviceDO::getLastInlineTime)
+        ;
+        return selectPage(reqVO, wrapper);
+    }
+
     default List<IotDeviceDO> selectByCodeIn(Collection<String> codes) {
         return selectList(new LambdaQueryWrapperX<IotDeviceDO>()
                 .in(IotDeviceDO::getDeviceCode, codes));

+ 2 - 2
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/job/InspectCreateOrderJob.java

@@ -71,12 +71,12 @@ public class InspectCreateOrderJob implements JobHandler {
                 iotInspectOrderService.createPlan(plan);
             }
         } else if ("day".equals(plan.getPlanUnit())){
-            DateTime dateTime = DateUtil.offsetDay(date, Integer.parseInt(String.valueOf(plan.getPlanCycle())));
+            DateTime dateTime = DateUtil.offsetDay(date, Integer.parseInt(StringUtils.substringBeforeLast(String.valueOf(plan.getPlanCycle()),".")));
             if (date1.compareTo(dateTime) > 0){
                 iotInspectOrderService.createPlan(plan);
             }
         } else if ("month".equals(plan.getPlanUnit())){
-            DateTime dateTime = DateUtil.offsetMonth(date, Integer.parseInt(String.valueOf(plan.getPlanCycle())));
+            DateTime dateTime = DateUtil.offsetMonth(date, Integer.parseInt(StringUtils.substringBeforeLast(String.valueOf(plan.getPlanCycle()),".")));
             if (date1.compareTo(dateTime) > 0){
                 iotInspectOrderService.createPlan(plan);
             }

+ 1 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/IotDeviceService.java

@@ -71,6 +71,7 @@ public interface IotDeviceService {
     List<IotDeviceDO> getSimpleDeviceList(IotDevicePageReqVO reqVO);
 
     PageResult<IotDeviceDO> getIotDeviceTdPage(IotDevicePageReqVO pageReqVO, List<String> codes);
+    PageResult<IotDeviceDO> getIotDeviceTdPageApp(IotDevicePageReqVO pageReqVO, List<String> codes);
 
     /**
      * 获得 设备bom 关联 关系 分页

+ 10 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/IotDeviceServiceImpl.java

@@ -257,6 +257,16 @@ public class IotDeviceServiceImpl implements IotDeviceService {
         return iotDeviceMapper.selectTdPage(pageReqVO,ids);
     }
 
+    @Override
+    public PageResult<IotDeviceDO> getIotDeviceTdPageApp(IotDevicePageReqVO pageReqVO, List<String> codes) {
+        Set<Long> ids = new HashSet<>();
+        if (Objects.nonNull(pageReqVO.getDeptId())) {
+            ids = deptService.getChildDeptIdListFromCache(pageReqVO.getDeptId());
+            ids.add(pageReqVO.getDeptId());
+        }
+        return iotDeviceMapper.selectTdPageApp(pageReqVO,ids);
+    }
+
     /* @Override
     public PageResult<IotDeviceDO> deviceAssociateBomPage(IotDevicePageReqVO pageReqVO) {
         Set<Long> ids = new HashSet<>();

+ 4 - 5
yudao-module-pms/yudao-module-pms-biz/src/main/resources/mapper/static/IotMaintainMapper.xml

@@ -44,11 +44,10 @@ select * from (select a.id,
                where order_status = 0
                  and deleted = false)fin
         <where>
-            <if test="reqVO.title!=null and reqVO.title!=''">
-                and fin.title LIKE CONCAT('%',#{reqVO.title},'%')
-            </if>
-            <if test="reqVO.type!=null and reqVO.type!=''">
-                and fin.type LIKE CONCAT('%',#{reqVO.type},'%')
+            <if test="reqVO.commonParam != null and reqVO.commonParam != ''">
+                and fin.title LIKE CONCAT('%', #{reqVO.commonParam}, '%')
+                OR fin.type LIKE CONCAT('%', #{reqVO.commonParam}, '%')
+                or fin.person LIKE CONCAT('%', #{reqVO.commonParam}, '%')
             </if>
         </where>
     </select>