This commit is contained in:
huangzj
2023-08-01 09:41:22 +08:00
parent 8bb6b04f59
commit 5fb9ec9660
2 changed files with 14 additions and 6 deletions

View File

@@ -14,9 +14,11 @@ import com.njcn.csdevice.mapper.CsLedgerMapper;
import com.njcn.csdevice.pojo.po.CsDeviceUserPO;
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
import com.njcn.csdevice.pojo.po.CsLedger;
import com.njcn.csdevice.pojo.vo.CsLedgerVO;
import com.njcn.csdevice.pojo.vo.DevCountVO;
import com.njcn.csdevice.service.CsDeviceUserPOService;
import com.njcn.csdevice.service.CsEquipmentDeliveryService;
import com.njcn.csdevice.service.ICsLedgerService;
import com.njcn.csdevice.service.RoleEngineerDevService;
import com.njcn.cswarn.api.CsEquipmentAlarmFeignClient;
import com.njcn.cswarn.pojo.parm.CsEquipmentAlarmParm;
@@ -28,6 +30,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
@@ -46,7 +49,7 @@ import static java.util.Objects.*;
@RequiredArgsConstructor
public class CsDeviceUserPOServiceImpl extends ServiceImpl<CsDeviceUserPOMapper, CsDeviceUserPO> implements CsDeviceUserPOService{
private final CsLedgerMapper csLedgerMapper;
private final ICsLedgerService iCsLedgerService;
private final CsEquipmentAlarmFeignClient csEquipmentAlarmFeignClient;
private final CsEquipmentDeliveryMapper csEquipmentDeliveryMapper;
private final RoleEngineerDevService roleEngineerDevService;
@@ -93,6 +96,10 @@ public class CsDeviceUserPOServiceImpl extends ServiceImpl<CsDeviceUserPOMapper,
DevCountVO devCountVO = new DevCountVO();
List<String> device = roleEngineerDevService.getDevice();
List<CsLedgerVO> deviceTree = iCsLedgerService.getDeviceTree();
List<String> collect1 = deviceTree.stream().filter(temp -> temp.getId().equals(id)).map(CsLedgerVO::getChildren).flatMap(Collection::stream).map(CsLedgerVO::getChildren).flatMap(Collection::stream).map(CsLedgerVO::getId).collect(Collectors.toList());
//求交集
device.retainAll(collect1);
if(CollectionUtils.isEmpty(device)){
devCountVO.setOnLineCount(0);
devCountVO.setOnLineDevs(new ArrayList<>());
@@ -107,14 +114,15 @@ public class CsDeviceUserPOServiceImpl extends ServiceImpl<CsDeviceUserPOMapper,
QueryWrapper<CsEquipmentDeliveryPO> queryWrapper = new QueryWrapper<>();
queryWrapper.in("id",device);
List<CsEquipmentDeliveryPO> csEquipmentDeliveryPOS = csEquipmentDeliveryMapper.selectList(queryWrapper);
devCountVO.setAllDevs(csEquipmentDeliveryPOS);
List<CsEquipmentDeliveryPO> collect = csEquipmentDeliveryPOS.stream().filter(temp -> temp.getRunStatus() == 1).collect(Collectors.toList());
List<CsEquipmentDeliveryPO> collect2= csEquipmentDeliveryPOS.stream().filter(temp -> temp.getRunStatus() == 2).collect(Collectors.toList());
devCountVO.setOnLineCount(collect.size());
devCountVO.setOnLineDevs(collect);
devCountVO.setOffLineCount(collect2.size());
devCountVO.setOffLineDevs(collect2);
devCountVO.setOnLineCount(collect2.size());
devCountVO.setOnLineDevs(collect2);
devCountVO.setOffLineCount(collect.size());
devCountVO.setOffLineDevs(collect);
}