Explorar o código

Merge remote-tracking branch 'origin/master'

zhangcl hai 1 mes
pai
achega
b89024cdb7

+ 2 - 0
yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/pojo/PageParam.java

@@ -33,4 +33,6 @@ public class PageParam implements Serializable {
     @Max(value = 100, message = "每页条数最大值为 100")
     private Integer pageSize = PAGE_SIZE;
 
+    @Schema(description = "通用查询参数")
+    private String commonParam;
 }

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

@@ -187,6 +187,23 @@ public class IotDeviceController {
                 pageResult.getTotal()));
     }
 
+    @GetMapping("/page/app")
+    @Operation(summary = "获得app端设备台账分页")
+    @PreAuthorize("@ss.hasPermission('rq:iot-device:query')")
+    public CommonResult<PageResult<IotDeviceRespVO>> getAppIotDevicePage(@Valid IotDevicePageReqVO pageReqVO, @Valid SortablePageParam pageParam) {
+        if (Objects.nonNull(pageParam)&&CollUtil.isNotEmpty(pageParam.getSortingFields())) {
+            pageParam.getSortingFields().get(0).setField("sortColumn");
+        }
+        PageResult<IotDeviceDO> pageResult = iotDeviceService.getIotDevicePageApp(pageReqVO, pageParam);
+        if (CollUtil.isEmpty(pageResult.getList())) {
+            return success(new PageResult<>(pageResult.getTotal()));
+        }
+        Map<Long, DeptDO> deptMap = deptService.getDeptMap(
+                convertList(pageResult.getList(), IotDeviceDO::getDeptId));
+        return success(new PageResult<>(IotDeviceConvert.INSTANCE.convertList(pageResult.getList(), deptMap),
+                pageResult.getTotal()));
+    }
+
     @GetMapping({"/list-all-simple", "/simple-list"})
     @Operation(summary = "获取设备精简信息列表", description = "只包含被开启的设备,主要用于前端的下拉选项")
     public CommonResult<List<IotDeviceSimpleRespVO>> getSimpleDeviceList(@Valid IotDevicePageReqVO reqVO) {

+ 1 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/dataobject/IotDeviceDO.java

@@ -162,4 +162,5 @@ public class IotDeviceDO extends BaseDO {
     private Double lng;
     private Double lat;
     private String location;
+    private String chargeName;
 }

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

@@ -8,7 +8,9 @@ import cn.iocoder.yudao.module.pms.controller.admin.iotmainworkorder.vo.IotMainW
 import cn.iocoder.yudao.module.pms.controller.admin.vo.IotDevicePageReqVO;
 import cn.iocoder.yudao.module.pms.controller.admin.vo.IotDeviceRespVO;
 import cn.iocoder.yudao.module.pms.dal.dataobject.IotDeviceDO;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Update;
@@ -59,6 +61,17 @@ public interface IotDeviceMapper extends BaseMapperX<IotDeviceDO> {
 //                .orderByAsc(IotDeviceDO::getSortColumn));
     }
 
+    default PageResult<IotDeviceDO> selectPageApp(IotDevicePageReqVO reqVO, Collection<Long> deptIds, SortablePageParam sortablePageParam) {
+        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())
+                ;
+        return selectPage(sortablePageParam, wrapper);
+    }
+
     default List<IotDeviceDO> selectList(IotDevicePageReqVO reqVO) {
         return selectList(new LambdaQueryWrapperX<IotDeviceDO>()
                 .inIfPresent(IotDeviceDO::getDeptId, reqVO.getDeviceIds())

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

@@ -75,6 +75,7 @@ public interface TDDeviceMapper extends BaseMapperX<TDDeviceDO> {
             "  ts BETWEEN #{ts}" +
             "  and #{ts1}"+
             "  and identity = #{colName}\n" +
+            "  and log_value != 0.0"+
             "  AND _c0 IS NOT NULL")
     @DS("tdengine")
     @TenantIgnore

+ 2 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/mysql/iotopeationfill/IotOpeationFillMapper.java

@@ -67,6 +67,8 @@ public interface IotOpeationFillMapper extends BaseMapperX<IotOpeationFillDO> {
     @TenantIgnore
     List<IotOpeationFillDO> fillListByUserId(IotOpeationFillRespVO vo);
     @TenantIgnore
+    List<IotOpeationFillDO> getOrderIds(IotOpeationFillRespVO vo);
+    @TenantIgnore
     List<IotOpeationFillDO> fillListByDeptId(IotOpeationFillRespVO vo);
     @TenantIgnore
     List<IotOpeationFillDO> rdList();

+ 1 - 1
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/mysql/iotopeationfill/IotOpeationFillOrderMapper.java

@@ -45,7 +45,7 @@ public interface IotOpeationFillOrderMapper extends BaseMapperX<IotOpeationFillO
                 .inIfPresent(IotOpeationFillOrderDO::getId, orderIds)
                 .eqIfPresent(IotOpeationFillOrderDO::getOrderType, reqVO.getOrderType())
                 .eqIfPresent(IotOpeationFillOrderDO::getOrderStatus, reqVO.getOrderStatus())
-                .likeIfPresent(IotOpeationFillOrderDO::getUserName, reqVO.getUserName())
+                .likeIfPresent(IotOpeationFillOrderDO::getUserName, reqVO.getOrderName())
                 .eqIfPresent(IotOpeationFillOrderDO::getUserId, reqVO.getUserId())
                 .betweenIfPresent(IotOpeationFillOrderDO::getCreateTime, reqVO.getCreateTime())
                 .orderByDesc(IotOpeationFillOrderDO::getCreateTime)

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

@@ -60,6 +60,7 @@ public interface IotDeviceService {
      * @return 设备台账分页
      */
     PageResult<IotDeviceDO> getIotDevicePage(IotDevicePageReqVO pageReqVO, SortablePageParam sortablePageParam);
+    PageResult<IotDeviceDO> getIotDevicePageApp(IotDevicePageReqVO pageReqVO, SortablePageParam sortablePageParam);
     void updateSort();
     /**
      * 获得设备精简列表

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

@@ -212,6 +212,18 @@ public class IotDeviceServiceImpl implements IotDeviceService {
         return iotDeviceMapper.selectPage(pageReqVO,ids, sortablePageParam);
     }
 
+    @Override
+    public PageResult<IotDeviceDO> getIotDevicePageApp(IotDevicePageReqVO pageReqVO, SortablePageParam sortablePageParam) {
+        PageUtils.buildDefaultSortingField(sortablePageParam, IotDeviceDO::getSortColumn);
+        Set<Long> ids = new HashSet<>();
+        if (Objects.nonNull(pageReqVO.getDeptId())) {
+            ids = deptService.getChildDeptIdListFromCache(pageReqVO.getDeptId());
+            ids.add(pageReqVO.getDeptId());
+        }
+
+        return iotDeviceMapper.selectPageApp(pageReqVO,ids, sortablePageParam);
+    }
+
     @Override
     public void updateSort() {
         List<IotDeviceDO> deviceDOS = iotDeviceMapper.selectList();

+ 1 - 1
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/iotopeationfill/IotOpeationFillServiceImpl.java

@@ -166,7 +166,7 @@ public class IotOpeationFillServiceImpl implements IotOpeationFillService {
         IotOpeationFillRespVO fillRespVO = new IotOpeationFillRespVO();
         fillRespVO.setOrgName(vo.getOrderName());
         fillRespVO.setDeptId(vo.getDeptId());
-        List<IotOpeationFillDO> fillList = iotOpeationFillMapper.fillListByUserId(fillRespVO);
+        List<IotOpeationFillDO> fillList = iotOpeationFillMapper.getOrderIds(fillRespVO);
         List<Long> orderIds = fillList.stream().map(IotOpeationFillDO::getOrderId).collect(Collectors.toList());
         return iotOpeationFillOrderMapper.selectPage1(vo,deptIds,orderIds);
     }

+ 25 - 3
yudao-module-pms/yudao-module-pms-biz/src/main/resources/mapper/static/IotOpeationFillMapper.xml

@@ -187,9 +187,9 @@
         )
         AND (
         <if test="orderId != null and orderId != ''">
-            a.order_id = #{orderId} AND
+            a.order_id = #{orderId}
         </if>
-        <if test="orgName != null and orgName != ''">
+        <!--<if test="orgName != null and orgName != ''">
             (
             a.device_name LIKE CONCAT('%', #{orgName}, '%')
             OR a.device_code LIKE CONCAT('%', #{orgName}, '%')
@@ -198,10 +198,32 @@
         </if>
         <if test="orgName == null or orgName == ''">
             1=1
-        </if>
+        </if>-->
         )
     </select>
 
+
+    <select id="getOrderIds" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillRespVO"
+            resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
+        select
+            distinct order_id
+        from rq_iot_opeation_fill
+        where
+            deleted = 0
+        and
+            order_id is not null
+        and(
+        <if test="orgName != null and orgName != ''">
+            (
+            device_name LIKE CONCAT('%', #{orgName}, '%')
+            OR device_code LIKE CONCAT('%', #{orgName}, '%')
+            )
+        </if>
+        <if test="orgName == null or orgName == ''">
+            1=1
+        </if>)
+    </select>
+
     <select id="fillListByDeptId" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillRespVO"
             resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
         select