Browse Source

修改在线率设备筛选条件

修改在线率查询条件
develop
zhaoxianglong 8 months ago
parent
commit
5dde7fce01
  1. 11
      zc-business/src/main/java/com/zc/business/controller/StatusController.java
  2. 2
      zc-business/src/main/java/com/zc/business/mapper/DcDeviceMapper.java
  3. 2
      zc-business/src/main/java/com/zc/business/service/IDcDeviceService.java
  4. 4
      zc-business/src/main/java/com/zc/business/service/impl/DcDeviceServiceImpl.java
  5. 5
      zc-business/src/main/resources/mapper/business/DcDeviceMapper.xml
  6. 3
      zc-business/src/main/resources/mapper/business/StatusMapper.xml

11
zc-business/src/main/java/com/zc/business/controller/StatusController.java

@ -129,7 +129,9 @@ public class StatusController extends BaseController {
@GetMapping ("/type")
public AjaxResult getTypeList()
{
List<DcDevice> dcDeviceList = dcDeviceService.numberOfDevicesByType();
DcDevice dcDevice = new DcDevice();
dcDevice.setUseState(1);
List<DcDevice> dcDeviceList = dcDeviceService.numberOfDevicesByType(dcDevice);
HashMap<String, String> itemTypeMap = new HashMap<>();
itemTypeMap.put("1-1", "高清网络枪型固定摄像机");
itemTypeMap.put("1-2", "高清网络球形摄像机");
@ -153,7 +155,6 @@ public class StatusController extends BaseController {
Status status = new Status();
status.setStartTime(todayStart);
status.setTime(currentTime);
status.setUseState(1);
List<Status> listStatus = statusService.list(status);
//根据时间分组
Map<Integer, List<Status>> map = listStatus.stream()
@ -184,9 +185,9 @@ public class StatusController extends BaseController {
//离线率
maps.put("failRate",failRate);
//已使用数量
maps.put("sumUseState",String.valueOf(groupItems.size()));
maps.put("sum",String.valueOf(groupItems.size()));
//总数
maps.put("sum", String.valueOf(dcDeviceList.stream().filter(item -> Objects.equals(item.getDeviceType(), entrys.getKey())).map(DcDevice::getSumAll).collect(Collectors.toList()).get(0)));
maps.put("sumUseState", String.valueOf(dcDeviceList.stream().filter(item -> Objects.equals(item.getDeviceType(), entrys.getKey())).map(DcDevice::getSumAll).collect(Collectors.toList()).get(0)));
if(itemTypeMap.get(entrys.getKey())!=null) {
subMap.put(itemTypeMap.get(entrys.getKey()), maps);
}
@ -205,8 +206,8 @@ public class StatusController extends BaseController {
maps.put("sucessRate",String.format("%.2f", sucessRate)+"%");
//离线率
maps.put("failRate",failRate);
List<DcDevice> list = dcDeviceService.list();
//已使用数量
List<DcDevice> list = dcDeviceService.list();
maps.put("sumUseState",String.valueOf(lastEntry.size()));
//总数
maps.put("sum",String.valueOf(list.size()));

2
zc-business/src/main/java/com/zc/business/mapper/DcDeviceMapper.java

@ -15,7 +15,7 @@ import java.util.List;
public interface DcDeviceMapper extends BaseMapper<DcDevice> {
List<DcDevice> selectDcDeviceList(DcDevice dcDevice);
List<DcDevice> numberOfDevicesByType();
List<DcDevice> numberOfDevicesByType(DcDevice dcDevice);
}

2
zc-business/src/main/java/com/zc/business/service/IDcDeviceService.java

@ -78,5 +78,5 @@ public interface IDcDeviceService extends IService<DcDevice> {
List<DcDevice> devicePileNumberQueryDevice(Map<String,Object> parameter);
List<DcDevice> numberOfDevicesByType();
List<DcDevice> numberOfDevicesByType(DcDevice dcDevice);
}

4
zc-business/src/main/java/com/zc/business/service/impl/DcDeviceServiceImpl.java

@ -448,8 +448,8 @@ public class DcDeviceServiceImpl extends ServiceImpl<DcDeviceMapper, DcDevice> i
}
@Override
public List<DcDevice> numberOfDevicesByType() {
return dcDeviceMapper.numberOfDevicesByType();
public List<DcDevice> numberOfDevicesByType(DcDevice dcDevice) {
return dcDeviceMapper.numberOfDevicesByType(dcDevice);
}
public static <T> List<T> castList(Object obj, Class<T> clazz) {

5
zc-business/src/main/resources/mapper/business/DcDeviceMapper.xml

@ -110,6 +110,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="numberOfDevicesByType" parameterType="dcDevice" resultMap="DcDevice">
SELECT COALESCE(child_type, device_type) AS device_type, COUNT(*) AS sumAll
FROM dc_device
<where>
<if test="useState!=null">
use_state = #{useState}
</if>
</where>
GROUP BY device_type, child_type;
</select>

3
zc-business/src/main/resources/mapper/business/StatusMapper.xml

@ -103,9 +103,6 @@
<if test="status.deviceId != null">
AND s.device_id = #{status.deviceId}
</if>
<if test="status.useState != null and status.useState != 0">
AND d.use_state = #{status.useState}
</if>
</where>
</select>

Loading…
Cancel
Save