TRX 1 yıl önce
ebeveyn
işleme
bac5879daf

+ 8 - 0
FullCardClient/src/main/java/com/zhongshu/card/client/model/school/DeviceBindSearch.java

@@ -7,6 +7,8 @@ import com.zhongshu.card.client.utils.type.PaymentModeType;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 
+import java.util.List;
+
 /**
  * @author TRX
  * @date 2024/7/2
@@ -38,6 +40,9 @@ public class DeviceBindSearch extends SuperSearch {
     @Schema(description = "商户Oid")
     private String shopInfoOid;
 
+    @Schema(description = "商户id集合")
+    private List<String> shopInfoOids;
+
     @Schema(description = "区域信息")
     private String areaId;
 
@@ -46,4 +51,7 @@ public class DeviceBindSearch extends SuperSearch {
 
     @Schema(description = "收款账号")
     private String receivingAccount;
+
+    @Schema(description = "是否查询所有的商户")
+    private Boolean isAllBusinessMain = Boolean.TRUE;
 }

+ 10 - 0
FullCardClient/src/main/java/com/zhongshu/card/client/service/school/DeviceBindService.java

@@ -16,4 +16,14 @@ public interface DeviceBindService {
     ResultContent<DeviceBindModel> getDetailById(String id);
 
     ResultContent<Page<DeviceBindModel>> page(DeviceBindSearch param, Pageable pageable);
+
+    /**
+     * 管理关联的商户设备列表
+     *
+     * @param param
+     * @param pageable
+     * @return
+     */
+    ResultContent<Page<DeviceBindModel>> busDevicePage(DeviceBindSearch param, Pageable pageable);
+
 }

+ 9 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/controller/school/DeviceBindController.java

@@ -64,6 +64,15 @@ public class DeviceBindController {
         return deviceBindService.page(param, pageable);
     }
 
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @Operation(summary = "用户所在的商户设备列表-分页查询", description = "用户所在的商户设备列表-分页查询")
+    @RequestMapping(value = {"busDevicePage"}, method = {RequestMethod.POST})
+    public ResultContent<Page<DeviceBindModel>> busDevicePage(
+            @Parameter(hidden = true) @PageableDefault(page = 0, size = 10) Pageable pageable,
+            @Parameter(required = false) DeviceBindSearch param) {
+        return deviceBindService.page(param, pageable);
+    }
+
     //----------------------------设备基础信息 end--------------------------
 
 }

+ 12 - 8
FullCardServer/src/main/java/com/zhongshu/card/server/core/dao/school/impl/DeviceBindDaoImpl.java

@@ -10,6 +10,7 @@ import com.zhongshu.card.server.core.domain.org.DeviceInfo;
 import com.zhongshu.card.server.core.domain.school.Area;
 import com.zhongshu.card.server.core.domain.school.DeviceBind;
 import com.zhongshu.card.server.core.util.CommonUtil;
+import org.apache.commons.lang3.ObjectUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Page;
@@ -39,32 +40,36 @@ public class DeviceBindDaoImpl extends BaseImpl implements DeviceBindDaoExtend {
 
     @Override
     public Page<DeviceBind> page(Pageable pageable, DeviceBindSearch param) {
-        Criteria criteria = buildCriteria(param);
+        Criteria criteria = buildCriteriaNotOid(param);
 
         if (param.getDeviceType() != null) {
             criteria.and("deviceType").is(param.getDeviceType());
         }
-
+        // 在线状态
         if (param.getOnLineState() != null) {
             criteria.and("onLineState").is(param.getOnLineState());
         }
-
+        // 所属区域
         if (StringUtils.isNotEmpty(param.getAreaId())) {
             criteria.and("area").is(Area.build(param.getAreaId()));
         }
-
+        // 所属项目code
         if (StringUtils.isNotEmpty(param.getProjectInfoCode())) {
             criteria.and("projectInfoCode").is(param.getProjectInfoCode());
         }
-
+        // 所属学校oid
         if (StringUtils.isNotEmpty(param.getSchoolInfoOid())) {
             criteria.and("schoolInfoOid").is(param.getSchoolInfoOid());
         }
-
+        // 所属商户oid
         if (StringUtils.isNotEmpty(param.getShopInfoOid())) {
             criteria.and("shopInfoOid").is(param.getShopInfoOid());
         }
-
+        // 所属商户oid集合
+        if (ObjectUtils.isNotEmpty(param.getShopInfoOids())) {
+            criteria.and("shopInfoOid").in(param.getShopInfoOids());
+        }
+        // 时间范围
         if (!CommonUtil.longIsEmpty(param.getStartTime()) && !CommonUtil.longIsEmpty(param.getEndTime())) {
             criteria.and("createTime").gte(param.getStartTime()).and("createTime").lte(param.getEndTime());
         }
@@ -91,7 +96,6 @@ public class DeviceBindDaoImpl extends BaseImpl implements DeviceBindDaoExtend {
                     Criteria.where("gateWayId").regex(pattern)
             );
         }
-
         Sort sort = buildSort(param);
         Query query = Query.query(criteria);
         query.with(sort);

+ 28 - 1
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/school/DeviceBindServiceImpl.java

@@ -1,5 +1,6 @@
 package com.zhongshu.card.server.core.service.school;
 
+import com.github.microservice.auth.security.type.AuthType;
 import com.github.microservice.components.data.base.util.PageEntityUtil;
 import com.zhongshu.card.client.model.school.*;
 import com.zhongshu.card.client.ret.ResultContent;
@@ -17,6 +18,7 @@ import com.zhongshu.card.server.core.service.base.SuperService;
 import com.zhongshu.card.server.core.service.org.DeviceInfoServiceImpl;
 import com.zhongshu.card.server.core.service.org.OrganizationServiceImpl;
 import com.zhongshu.card.server.core.util.BeanUtils;
+import com.zhongshu.card.server.core.util.CommonUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.ObjectUtils;
 import org.apache.commons.lang3.StringUtils;
@@ -26,6 +28,10 @@ import org.springframework.data.domain.Pageable;
 import org.springframework.stereotype.Service;
 import org.springframework.util.Assert;
 
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
 /**
  * @author TRX
  * @date 2024/7/2
@@ -159,8 +165,29 @@ public class DeviceBindServiceImpl extends SuperService implements DeviceBindSer
      */
     @Override
     public ResultContent<Page<DeviceBindModel>> page(DeviceBindSearch param, Pageable pageable) {
-        initOidSearchParam(param);
+        // 找出用户所有商户oid集合
+        List<String> shopOids = new ArrayList<String>();
+        if (CommonUtil.booleanIsTrue(param.getIsAllBusinessMain())) {
+            // 查询当前用户所有的商户信息
+            List<Organization> orgs = organizationService.getUserAllOrgs(getCurrentUserId(), AuthType.BusinessMain);
+            if (ObjectUtils.isNotEmpty(orgs)) {
+                shopOids = orgs.stream().map(it -> it.getOid()).collect(Collectors.toList());
+            }
+        } else {
+            if (StringUtils.isNotEmpty(param.getShopInfoOid())) {
+                shopOids.add(param.getShopInfoOid());
+            }
+        }
+        if (ObjectUtils.isEmpty(shopOids)) {
+            return ResultContent.buildFail("请选择查询商户或所有的");
+        }
+        Page<DeviceBind> page = deviceBindDao.page(pageable, param);
+        return ResultContent.buildSuccess(PageEntityUtil.concurrent2PageModel(page, this::toModel));
+    }
 
+    @Override
+    public ResultContent<Page<DeviceBindModel>> busDevicePage(DeviceBindSearch param, Pageable pageable) {
+        initOidSearchParam(param);
         Page<DeviceBind> page = deviceBindDao.page(pageable, param);
         return ResultContent.buildSuccess(PageEntityUtil.concurrent2PageModel(page, this::toModel));
     }

+ 7 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/util/CommonUtil.java

@@ -384,6 +384,13 @@ public class CommonUtil {
         return false;
     }
 
+    public static boolean booleanIsTrue(Boolean b) {
+        if (b != null && b) {
+            return true;
+        }
+        return false;
+    }
+
     /**
      * 小时转为分钟,,保留整数 (最小 1 分钟)
      *