Procházet zdrojové kódy

PC和小程序硬件查询接口添加类型查询参数

xuxiaofei před 2 roky
rodič
revize
c4e56e8caf

+ 8 - 1
zd-model/src/main/java/com/zd/model/entity/SubQueryConfig.java

@@ -77,7 +77,10 @@ public class SubQueryConfig {
      */
     public static final SubQueryConfig subQueryConfigWran;
 
-
+    /**
+     * 硬件类型集合
+     */
+    public Long[] typeCollection;
 
     static {
 
@@ -202,6 +205,10 @@ public class SubQueryConfig {
         this.conversionDictSubName = conversionDictSubName;
     }
 
+    public Long[] getTypeCollection() {        return typeCollection;    }
+
+    public void setTypeCollection(Long[] typeCollection) {        this.typeCollection = typeCollection;    }
+
     public static enum mode{
         //无权限
         none,

+ 5 - 2
zd-modules/zd-base/src/main/java/com/zd/base/app/controller/LaboratoryApi.java

@@ -36,13 +36,16 @@ public class LaboratoryApi {
 
     /**
      * 预警 :实验室详情
+     * typeCollection 硬件类型集合(非必填)
      * @return
      */
     @GetMapping("/{id}")
     @ApiOperation("实验室详情")
-    public R querySub(@PathVariable("id") Long id)
+    public R querySub(@PathVariable("id") Long id,Long[] typeCollection)
     {
-        return remoteSubQueryService.getSafeWarnCount(id, SubQueryConfig.subQueryConfigWran);
+        SubQueryConfig subQueryConfig = SubQueryConfig.subQueryConfigWran;
+        subQueryConfig.setTypeCollection(typeCollection);
+        return remoteSubQueryService.getSafeWarnCount(id, subQueryConfig);
     }
 
     /**

+ 3 - 2
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/controller/LabSubMangerController.java

@@ -104,13 +104,14 @@ public class LabSubMangerController extends BaseController {
      * 查询实验室详情
      * @param id 实验室ID
      * @param type 1 只查硬件数据, 0 查全部详情
+     * @param typeCollection   设备类型集合(非必须)
      * @return
      */
     @ApiOperation("查询实验室详情")
     @GetMapping("/query/{id}/{type}")
     @PreAuthorize(hasPermi = PerPrefix.LABORATORY_SUBJECT + PerFun.QUERY)
-    public ResultData<LabSubjectControllerVO> querySubById(@PathVariable("id") Long id, @PathVariable("type") Integer type) {
-        return ResultData.success(subjectManagerService.querySubById(id, type));
+    public ResultData<LabSubjectControllerVO> querySubById(@PathVariable("id") Long id, @PathVariable("type") Integer type,Long[] typeCollection) {
+        return ResultData.success(subjectManagerService.querySubById(id, type,typeCollection));
     }
 
     /**

+ 15 - 0
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/domain/LabHardware.java

@@ -11,6 +11,7 @@ import io.swagger.annotations.ApiModelProperty;
 import org.hibernate.validator.constraints.Length;
 
 import java.util.Date;
+import java.util.List;
 
 /**
  * 硬件对象 lab_hardware
@@ -205,6 +206,12 @@ public class LabHardware extends BaseEntity {
     @ApiModelProperty(value = "是否灭火主机")
     private Integer isPcfire;
 
+    @ApiModelProperty(value = "设备类型集合")
+    private Long[] typeCollection;
+
+    @ApiModelProperty(value = "实验室id集合")
+    private Long[] subIds;
+
     public Integer getManufacturerType() {
         return manufacturerType;
     }
@@ -495,4 +502,12 @@ public class LabHardware extends BaseEntity {
     public void setControlScope(String controlScope) {
         this.controlScope = controlScope;
     }
+
+    public Long[] getTypeCollection() {        return typeCollection;    }
+
+    public void setTypeCollection(Long[] typeCollection) {        this.typeCollection = typeCollection;    }
+
+    public Long[] getSubIds() {        return subIds;    }
+
+    public void setSubIds(Long[] subIds) {        this.subIds = subIds;    }
 }

+ 6 - 0
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/mapper/LabHardwareMapper.java

@@ -28,6 +28,12 @@ public interface LabHardwareMapper {
      */
     List<LabHardware> selectLabHardwareBySubIds(Long... ids);
 
+    /***
+     * 硬件查询
+     * @param hardware
+     * @return
+     */
+    List<LabHardware> selectLabHardwareByParameter(LabHardware hardware);
 
     /**
      * 查询硬件列表-根据实验室IDS(排除一键灭火类型)

+ 15 - 7
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/LabSubjectManagerService.java

@@ -554,12 +554,12 @@ public class LabSubjectManagerService {
 //         return createSubControllerVO(labSubjects, true, true, true, true, true);
     }
 
-    public LabSubjectControllerVO querySubById(Long id, Integer type) {
+    public LabSubjectControllerVO querySubById(Long id, Integer type,Long[] typeCollection) {
         LabSubject subject = new LabSubject();
         subject.setId(id);
         List<LabSubjectVO> labSubjects = subjectService.selectLabSubjectListAuthByPc(subject);
-        List<LabSubjectControllerVO> list = createSubControllerVO2(labSubjects, true, true, true, true, true);
-        if(list.size() > 0){
+        List<LabSubjectControllerVO> list = createSubControllerVO2(labSubjects,typeCollection, true, true, true, true, true);
+        if(list !=null && list.size() > 0){
             LabSubjectControllerVO subjectControllerVO = list.get(0);
             subjectControllerVO.setSafeUserNameAdminPhone(labSubjectMapper.queryUserNameBySafeUserInfo(subjectControllerVO.getSafeUserId()));
             subjectControllerVO.setSafeUserName(labSubjectMapper.queryUserNameBySafeUserId(subjectControllerVO.getSafeUserId()));
@@ -1211,7 +1211,7 @@ public class LabSubjectManagerService {
      * @return
      */
     @Deprecated
-    private List<LabSubjectControllerVO> createSubControllerVO2(List<? extends LabSubject> labSubjects, boolean flag, boolean iflabSubClassVOS, boolean iflabHardwares, boolean iflabSensors, boolean ifFunction) {
+    private List<LabSubjectControllerVO> createSubControllerVO2(List<? extends LabSubject> labSubjects,Long[] typeCollection, boolean flag, boolean iflabSubClassVOS, boolean iflabHardwares, boolean iflabSensors, boolean ifFunction) {
         List<LabSubjectControllerVO> list = null;
         if (CollUtil.isNotEmpty(labSubjects)) {
             Long[] longs = labSubjects.stream().map(a -> a.getId()).toArray(Long[]::new);
@@ -1223,7 +1223,11 @@ public class LabSubjectManagerService {
             List<LabHardware> labHardwares = null;
             if (iflabHardwares) {
                 //1.可控设备
-                labHardwares = hardwareMapper.selectLabHardwareBySubIds(longs);
+                //labHardwares = hardwareMapper.selectLabHardwareBySubIds(longs);
+                LabHardware hardware = new LabHardware();
+                hardware.setSubIds(longs);
+                hardware.setTypeCollection(typeCollection);
+                labHardwares = hardwareMapper.selectLabHardwareByParameter(hardware);
             }
             List<LabSensor> labSensors = null;
             boolean flagUpdate = false;
@@ -1347,9 +1351,13 @@ public class LabSubjectManagerService {
      * @return
      */
     @Async("labExecutor")
-    public CompletableFuture<Integer> queryHardwares(Map<Long, SubDiyVO> subDiyVOMap, Long... longs) {
+    public CompletableFuture<Integer> queryHardwares(Long[] typeCollection,Map<Long, SubDiyVO> subDiyVOMap, Long... longs) {
         int re = 0;
-        List<LabHardware> labHardwares = hardwareMapper.selectLabHardwareBySubIds(longs);
+        //List<LabHardware> labHardwares = hardwareMapper.selectLabHardwareBySubIds(longs);
+        LabHardware lhd = new LabHardware();
+        lhd.setSubIds(longs);
+        lhd.setTypeCollection(typeCollection);
+        List<LabHardware> labHardwares = hardwareMapper.selectLabHardwareByParameter(lhd);
         //传感器和可控设备都转为vo数据,并映射为map表
         Map<Long, List<HardwareCVO>> mapHardwareCVO = Optional.ofNullable(labHardwares).orElse(new ArrayList<>(0)).stream().map(a -> {
             HardwareCVO hardware = getHardwareCVO(a);

+ 1 - 1
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/SubQueryManager.java

@@ -244,7 +244,7 @@ public class SubQueryManager {
         //===================硬件设备开始
         if(subQueryConfig.getHardware())
         {
-            CompletableFuture<Integer> integerCompletableFuture = subjectManagerService.queryHardwares(subDiyVOMap, longs);
+            CompletableFuture<Integer> integerCompletableFuture = subjectManagerService.queryHardwares(subQueryConfig.getTypeCollection(),subDiyVOMap, longs);
             completableFutures.add(integerCompletableFuture);
         }
         //===================硬件设备结束

+ 20 - 0
zd-modules/zd-modules-laboratory/src/main/resources/mapper/laboratory/LabHardwareMapper.xml

@@ -213,6 +213,26 @@
         </foreach>
     </select>
 
+    <!--   硬件设备查询 -->
+    <select id="selectLabHardwareByParameter" resultMap="LabHardwareResult">
+        <include refid="selectLabHardwareVo"/>
+        <where>
+            <if test="subIds != null and subIds.length > 0">
+                and xx.subject_id in
+                <foreach item="id" collection="subIds" open="(" separator="," close=")">
+                    #{id}
+                </foreach>
+            </if>
+
+            <if test="typeCollection != null and typeCollection.length > 0">
+                and xx.type in
+                <foreach item="item" collection="typeCollection" open="(" separator="," close=")">
+                    #{item}
+                </foreach>
+            </if>
+        </where>
+    </select>
+
     <!--   通过实验室ids查询设备 -->
     <select id="selLabHardwareBySubIds" resultMap="LabHardwareResult">
         <include refid="selectLabHardwareVo"/>