Skip to content

Commit

Permalink
适配 spring-boot 2.4.x 版本配置文件,并修复 1.3.2.SR 版本
Browse files Browse the repository at this point in the history
  • Loading branch information
pnoker committed Jun 8, 2021
1 parent 9ee6f6c commit df48129
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public Page<PointValue> list(PointValueDto pointValueDto) {

Pages pages = Optional.ofNullable(pointValueDto.getPage()).orElse(new Pages());
if (pages.getStartTime() > 0 && pages.getEndTime() > 0 && pages.getStartTime() <= pages.getEndTime()) {
criteria.and("originTime").gte(pages.getStartTime()).lte(pages.getEndTime());
criteria.and("originTime").gte(new Date(pages.getStartTime())).lte(new Date(pages.getEndTime()));
}

Future<Long> count = threadPoolExecutor.submit(() -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dc3.center.manager.mapper.DeviceMapper;
import com.dc3.center.manager.service.DeviceService;
import com.dc3.center.manager.service.ProfileBindService;
import com.dc3.center.manager.service.*;
import com.dc3.common.bean.Pages;
import com.dc3.common.constant.Common;
import com.dc3.common.dto.DeviceDto;
import com.dc3.common.exception.DuplicateException;
import com.dc3.common.exception.NotFoundException;
import com.dc3.common.exception.ServiceException;
import com.dc3.common.model.Device;
import com.dc3.common.model.Point;
import com.dc3.common.model.Profile;
import com.dc3.common.model.ProfileBind;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cache.annotation.CacheEvict;
Expand Down Expand Up @@ -55,6 +56,13 @@ public class DeviceServiceImpl implements DeviceService {
@Resource
private ProfileBindService profileBindService;

@Resource
private NotifyService notifyService;
@Resource
private ProfileService profileService;
@Resource
private PointService pointService;

@Override
@Caching(
put = {
Expand All @@ -74,8 +82,11 @@ public Device add(Device device) {
} catch (NotFoundException notFoundException) {
if (deviceMapper.insert(device) > 0) {
device.getProfileIds().forEach(profileId -> {
ProfileBind profileBind = new ProfileBind(profileId, device.getId());
profileBindService.add(profileBind);
Profile profile = profileService.selectById(profileId);
profileBindService.add(new ProfileBind(profile.getId(), device.getId()));
notifyService.notifyDriverProfile(Common.Driver.Profile.ADD, profile);
List<Point> points = pointService.selectByProfileId(profile.getId());
points.forEach(point -> notifyService.notifyDriverPoint(Common.Driver.Point.ADD, point));
});
Device select = deviceMapper.selectById(device.getId());
select.setProfileIds(device.getProfileIds());
Expand Down Expand Up @@ -122,8 +133,14 @@ public Device update(Device device) {
add.removeAll(oldProfileIds);
Set<Long> delete = new HashSet<>(oldProfileIds);
delete.removeAll(newProfileIds);
add.forEach(id -> profileBindService.add(new ProfileBind(id, device.getId())));
delete.forEach(id -> profileBindService.deleteByProfileIdAndDeviceId(id, device.getId()));
add.forEach(profileId -> {
Profile profile = profileService.selectById(profileId);
profileBindService.add(new ProfileBind(profile.getId(), device.getId()));
notifyService.notifyDriverProfile(Common.Driver.Profile.ADD, profile);
List<Point> points = pointService.selectByProfileId(profile.getId());
points.forEach(point -> notifyService.notifyDriverPoint(Common.Driver.Point.ADD, point));
});
delete.forEach(profileId -> profileBindService.deleteByProfileIdAndDeviceId(profileId, device.getId()));
if (deviceMapper.updateById(device) > 0) {
Device select = deviceMapper.selectById(device.getId());
select.setProfileIds(newProfileIds);
Expand Down

0 comments on commit df48129

Please sign in to comment.