Selaa lähdekoodia

1.修改心跳信号始终保存最新的连接通道。
2.测温记录查询增加单位及人员去重。

zhengqiang 5 vuotta sitten
vanhempi
commit
28648695a4

+ 12 - 1
common/src/main/resources/mapper/base/PersonDeviceLog.xml

@@ -119,6 +119,14 @@
                     #{item}
                 </foreach>
             </if>
+            <if test="searchParams.companyCode != null">
+                and exists (
+                    select t1.id_ from base_person_info t1,base_company_info t2
+                    where t1.company_id =t2.id_
+                    and t2.code_ like #{searchParams.companyCode}
+                    and t1.del_flag=0 and t1.id_ = a.person_id
+                )
+            </if>
             <if test="searchParams.personId != null">
                 and a.person_id = #{searchParams.personId}
             </if>
@@ -149,7 +157,7 @@
                   and a.temperature_ >= #{searchParams.minTemperature}
                 ]]>
             </if>
-            <if test="searchParams.maxTemperature != null">
+            <if test="searchParams.maxTempedistinctrature != null">
                 <![CDATA[
                   and a.temperature_ <= #{searchParams.maxTemperature}
                 ]]>
@@ -158,6 +166,9 @@
                 and a.match_msg like #{searchParams.matchMsg}
             </if>
         </where>
+        <if test="searchParams.distinct">
+            group by a.person_id
+        </if>
         <foreach item="sort" collection="sortList"  open="order by" separator=",">
             ${sort.name} ${sort.order}
         </foreach>

+ 5 - 3
lapi/src/main/java/com/jpsoft/smart/lapi/handler/HeartReportHandler.java

@@ -81,13 +81,15 @@ public class HeartReportHandler extends SimpleChannelInboundHandler<HeartReportI
             ctx.channel().attr(LapiAttrKeys.DEVICE_NO).set(deviceNo);
         }
 
-        //将连接保存到map中,以便发数据
-        if(!activeLapiChannelMap.containsKey(deviceNo)){
+        if (activeLapiChannelMap.containsKey(deviceNo)) {
+            activeLapiChannelMap.get(deviceNo).setChannel(ctx.channel());
+        }
+        else {
             LapiChannel lapiChannel = new LapiChannel();
             lapiChannel.setChannel(ctx.channel());
             lapiChannel.setReceivePacketQueueMap(new ConcurrentHashMap<>());
 
-            activeLapiChannelMap.put(deviceNo,lapiChannel);
+            activeLapiChannelMap.put(deviceNo, lapiChannel);
         }
     }
 }

+ 26 - 4
web/src/main/java/com/jpsoft/smart/modules/base/controller/PersonDeviceLogController.java

@@ -67,16 +67,22 @@ public class PersonDeviceLogController {
     @ApiOperation(value="列表")
     @RequestMapping(value = "pageList",method = RequestMethod.POST)
     @ApiImplicitParams({
+            @ApiImplicitParam(name = "companyId",value = "所属单位编号", paramType = "query"),
+            @ApiImplicitParam(name = "subordinate",value = "会否保护下级单位", required = false, paramType = "query",dataType = "String"),
             @ApiImplicitParam(name = "deviceNo",value = "设备编号", paramType = "query"),
             @ApiImplicitParam(name = "aliasName",value = "设备别名", paramType = "query"),
             @ApiImplicitParam(name = "personName",value = "人员姓名", paramType = "query"),
             @ApiImplicitParam(name = "timeRanges",value = "时间范围", paramType = "query"),
             @ApiImplicitParam(name = "temperatureRanges",value = "温度范围", paramType = "query"),
-            @ApiImplicitParam(name = "matchMsg",value = "匹配状态", paramType = "query")
+            @ApiImplicitParam(name = "matchMsg",value = "匹配状态", paramType = "query"),
+            @ApiImplicitParam(name = "distinct",value = "是否去重", paramType = "query")
     })
     public MessageResult<Map> pageList(
+            String companyId,
+            @RequestParam(value="subordinate",defaultValue="false")  Boolean subordinate,
             String deviceNo,String aliasName,String personName,
             String timeRanges,String temperatureRanges,String matchMsg,
+            @RequestParam(value="distinct",defaultValue="false") Boolean distinct,
             @RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
             @RequestParam(value="pageSize",defaultValue="20") int pageSize,
             @RequestAttribute String subject){
@@ -88,6 +94,23 @@ public class PersonDeviceLogController {
 
         Map<String,Object> searchParams = new HashMap<>();
 
+        if (StringUtils.isNotEmpty(companyId)){
+            searchParams.put("companyId", companyId);
+
+            CompanyInfo companyInfo = companyInfoService.get(companyId);
+
+            if(subordinate){
+                searchParams.put("companyCode", companyInfo.getCode() + "%");
+            }
+            else {
+                searchParams.put("companyCode", companyInfo.getCode());
+            }
+        }
+
+        if (distinct!=null){
+            searchParams.put("distinct",distinct);
+        }
+
         List<Sort> sortList = new ArrayList<>();
         sortList.add(new Sort("a.record_time","desc"));
 
@@ -96,9 +119,9 @@ public class PersonDeviceLogController {
 
         if(!isSysAdmin){
             User user = userService.get(subject);
-            String companyId = user.getCompanyId();
+            String userCompanyId = user.getCompanyId();
 
-            List<DeviceInfo> deviceInfoList = deviceInfoService.findByCompanyId(companyId);
+            List<DeviceInfo> deviceInfoList = deviceInfoService.findByCompanyId(userCompanyId);
             List<String> deviceIdList = new ArrayList<String>();
 
             for (DeviceInfo deviceInfo:deviceInfoList) {
@@ -125,7 +148,6 @@ public class PersonDeviceLogController {
             searchParams.put("matchMsg","%"+matchMsg+"%");
         }
 
-
         if(StringUtil.isNotEmpty(timeRanges)){
             String[] timeRangeArray = timeRanges.split(",");
             String beginTime = "";