| | |
| | | import com.doumee.core.utils.Constants; |
| | | import com.doumee.core.utils.DateUtil; |
| | | import com.doumee.core.utils.Utils; |
| | | import com.doumee.dao.business.dto.YwConditionerLockDTO; |
| | | import com.doumee.dao.business.dto.YwConditionerOperateDTO; |
| | | import com.doumee.dao.business.YwConditionerGatewayMapper; |
| | | import com.doumee.dao.business.YwConditionerMapper; |
| | | import com.doumee.dao.business.model.YwConditioner; |
| | | import com.doumee.dao.business.model.YwConditionerActions; |
| | | import com.doumee.dao.business.model.YwConditionerGateway; |
| | | import com.doumee.service.business.ConditionerBizService; |
| | | import com.doumee.service.business.YwConditionerActionsService; |
| | | import com.doumee.service.business.YwConditionerService; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 空调设备信息Service实现 |
| | |
| | | |
| | | @Autowired |
| | | private YwConditionerMapper ywConditionerMapper; |
| | | @Autowired |
| | | private YwConditionerGatewayMapper gatewayMapper; |
| | | @Autowired |
| | | private ConditionerBizService conditionerBizService; |
| | | @Autowired |
| | | private YwConditionerActionsService ywConditionerActionsService; |
| | | |
| | | @Override |
| | | public Integer create(YwConditioner ywConditioner) { |
| | |
| | | IPage<YwConditioner> iPage = ywConditionerMapper.selectJoinPage(page, YwConditioner.class, queryWrapper); |
| | | return PageData.from(iPage); |
| | | } |
| | | |
| | | @Override |
| | | public PageData<YwConditioner> findCardPage(PageWrap<YwConditioner> pageWrap) { |
| | | IPage<YwConditioner> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity()); |
| | | Utils.MP.blankToNull(pageWrap.getModel()); |
| | | YwConditioner model = pageWrap.getModel() == null ? new YwConditioner() : pageWrap.getModel(); |
| | | MPJLambdaWrapper<YwConditioner> queryWrapper = new MPJLambdaWrapper<>(); |
| | | queryWrapper.selectAll(YwConditioner.class) |
| | | .eq(YwConditioner::getIsdeleted, Constants.ZERO) |
| | | .isNotNull(YwConditioner::getPlatformDevId) |
| | | .and(StringUtils.isNotBlank(model.getDevKeyword()), w -> w |
| | | .like(YwConditioner::getName, model.getDevKeyword()) |
| | | .or().like(YwConditioner::getCode, model.getDevKeyword()) |
| | | .or().like(YwConditioner::getRoomName, model.getDevKeyword())) |
| | | .eq(StringUtils.isNotBlank(model.getOnlineFilter()), YwConditioner::getOnline, model.getOnlineFilter()) |
| | | .eq(model.getPwrFilter() != null, YwConditioner::getPwr, model.getPwrFilter()) |
| | | .eq(StringUtils.isNotBlank(model.getWgMacFilter()), YwConditioner::getWgMac, model.getWgMacFilter()) |
| | | .orderByAsc(YwConditioner::getWgQid) |
| | | .orderByAsc(YwConditioner::getId); |
| | | PageData<YwConditioner> pageData = PageData.from( |
| | | ywConditionerMapper.selectJoinPage(page, YwConditioner.class, queryWrapper)); |
| | | fillGatewayBzFromGateway(pageData.getRecords()); |
| | | return pageData; |
| | | } |
| | | |
| | | /** |
| | | * 从本地网关镜像表 yw_conditioner_gateway 关联填充备注(优先平台网关ID,其次 MAC) |
| | | */ |
| | | private void fillGatewayBzFromGateway(List<YwConditioner> records) { |
| | | if (CollectionUtils.isEmpty(records)) { |
| | | return; |
| | | } |
| | | List<String> macs = records.stream() |
| | | .map(YwConditioner::getWgMac) |
| | | .filter(StringUtils::isNotBlank) |
| | | .distinct() |
| | | .collect(Collectors.toList()); |
| | | List<Integer> platformWgIds = records.stream() |
| | | .map(YwConditioner::getWgId) |
| | | .filter(Objects::nonNull) |
| | | .distinct() |
| | | .collect(Collectors.toList()); |
| | | if (macs.isEmpty() && platformWgIds.isEmpty()) { |
| | | return; |
| | | } |
| | | QueryWrapper<YwConditionerGateway> gwQuery = new QueryWrapper<>(); |
| | | gwQuery.lambda().eq(YwConditionerGateway::getIsdeleted, Constants.ZERO); |
| | | if (!macs.isEmpty() && !platformWgIds.isEmpty()) { |
| | | gwQuery.lambda().and(w -> w.in(YwConditionerGateway::getWgMac, macs) |
| | | .or().in(YwConditionerGateway::getPlatformWgId, platformWgIds)); |
| | | } else if (!macs.isEmpty()) { |
| | | gwQuery.lambda().in(YwConditionerGateway::getWgMac, macs); |
| | | } else { |
| | | gwQuery.lambda().in(YwConditionerGateway::getPlatformWgId, platformWgIds); |
| | | } |
| | | List<YwConditionerGateway> gateways = gatewayMapper.selectList(gwQuery); |
| | | Map<String, String> bzByMac = new HashMap<>(); |
| | | Map<Integer, String> bzByPlatformWgId = new HashMap<>(); |
| | | for (YwConditionerGateway gw : gateways) { |
| | | if (StringUtils.isNotBlank(gw.getWgBz())) { |
| | | if (StringUtils.isNotBlank(gw.getWgMac())) { |
| | | bzByMac.putIfAbsent(gw.getWgMac().trim(), gw.getWgBz()); |
| | | } |
| | | if (gw.getPlatformWgId() != null) { |
| | | bzByPlatformWgId.putIfAbsent(gw.getPlatformWgId(), gw.getWgBz()); |
| | | } |
| | | } |
| | | } |
| | | for (YwConditioner row : records) { |
| | | String bz = null; |
| | | if (StringUtils.isNotBlank(row.getWgMac())) { |
| | | bz = bzByMac.get(row.getWgMac().trim()); |
| | | } |
| | | if (StringUtils.isBlank(bz) && row.getWgId() != null) { |
| | | bz = bzByPlatformWgId.get(row.getWgId()); |
| | | } |
| | | if (StringUtils.isNotBlank(bz)) { |
| | | row.setWgBz(bz); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public String syncAll() { |
| | | return conditionerBizService.syncAll(); |
| | | } |
| | | |
| | | @Override |
| | | public String syncDevicesAndStatus() { |
| | | return conditionerBizService.syncIndoorUnits(); |
| | | } |
| | | |
| | | @Override |
| | | public String operate(YwConditionerOperateDTO dto, LoginUserInfo user) { |
| | | return conditionerBizService.operate(dto, user); |
| | | } |
| | | |
| | | @Override |
| | | public String lock(YwConditionerLockDTO dto, LoginUserInfo user) { |
| | | return conditionerBizService.lock(dto, user); |
| | | } |
| | | |
| | | @Override |
| | | public PageData<YwConditionerActions> historyPage(PageWrap<YwConditionerActions> pageWrap) { |
| | | return ywConditionerActionsService.findPage(pageWrap); |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> gatewayOptions() { |
| | | return conditionerBizService.gatewayOptions(); |
| | | } |
| | | } |