2021与蓝度共同重构项目,服务端
liuhaonan
2022-04-11 e861c8ea2fd047f31d5b4827fb2a598af60e9378
ip音柱文件上传
已修改4个文件
55 ■■■■■ 文件已修改
ximon-admin/pom.xml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/service/IpVolumeFileService.java 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightService.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleBindingService.java 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/pom.xml
@@ -117,6 +117,10 @@
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <executable>true</executable>
                    <includeSystemScope>true</includeSystemScope>
                </configuration>
            </plugin>
        </plugins>
    </build>
ximon-admin/src/main/java/com/sandu/ximon/admin/service/IpVolumeFileService.java
@@ -53,15 +53,42 @@
    public boolean deleteFile(Long fileId) {
        IpVolumeFile byId = getById(fileId);
        String bucketName;
        if (SecurityUtils.getClientId() == null) {
            bucketName = MinIoConstant.ADMIN_BROADCAST_FILE.getBucketName();
        } else {
            bucketName = MinIoConstant.BROADCAST_FILE.getBucketName() + SecurityUtils.getUserId();
        }
        if (byId == null) {
            throw new BusinessException("找不到对应文件");
        }
        boolean b = minIoUtil.deleteFile(bucketName, byId.getFileName());
//        if (!b) {
//            throw new BusinessException("服务器删除失败");
//        }
        return removeById(fileId);
    }
    public LambdaQueryWrapper<IpVolumeFile> listFile(BaseConditionVO baseConditionVO, String keyword) {
        PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize());
        LambdaQueryWrapper<IpVolumeFile> wrapper = Wrappers.lambdaQuery(IpVolumeFile.class).eq(IpVolumeFile::getClientId, clientService.getClientId());
        LambdaQueryWrapper<IpVolumeFile> wrapper;
        if (SecurityUtils.getClientId() == null) {
            wrapper = Wrappers.lambdaQuery(IpVolumeFile.class);
        } else {
            if (clientService.findClientId()) {
                wrapper = Wrappers.lambdaQuery(IpVolumeFile.class).eq(IpVolumeFile::getUserId, SecurityUtils.getUserId());
            } else {
                wrapper = Wrappers.lambdaQuery(IpVolumeFile.class).eq(IpVolumeFile::getClientId, clientService.getClientId())
                        .or(file -> {
                            file.eq(IpVolumeFile::getClientId, SecurityUtils.getUserId());
                        });
            }
        }
        if (keyword.isEmpty()) {
            return wrapper;
        } else {
@@ -74,7 +101,7 @@
     * 文件上传
     *
     * @param file
     * @param userId
     * @param
     * @return
     */
    public FileUploadDto upload(MultipartFile file) {
ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightService.java
@@ -22,6 +22,8 @@
import com.sandu.ximon.dao.bo.LightBo;
import com.sandu.ximon.dao.domain.Light;
import com.sandu.ximon.dao.domain.LightReportData;
import com.sandu.ximon.dao.domain.Pole;
import com.sandu.ximon.dao.domain.PoleBinding;
import com.sandu.ximon.dao.enums.DeviceRespStatusEnums;
import com.sandu.ximon.dao.mapper.LightMapper;
import lombok.AllArgsConstructor;
@@ -46,6 +48,8 @@
    private final RedisService redisService;
    private final LightReportDataService lightReportDataService;
    private final PoleBindingService bindingService;
    private final PoleService poleService;
    /**
     * 录入当前设备码的路灯数据
@@ -94,6 +98,17 @@
        if (CollectionUtil.isNotEmpty(deviceCodeList)) {
            List<LightReportData> reportDataList = lightReportDataService.getNewestReportByDeviceCode(deviceCodeList);
            for (LightBo lightBo : listLight) {
                deviceCodeList.forEach(code -> {
                            PoleBinding bind = bindingService.getPoleIdByMac(code);
                            if (bind != null&&lightBo.getDeviceCode().equals(bind.getDeviceCode())) {
                                Long poleId = bind.getPoleId();
                                    Pole pole = poleService.getById(poleId);
                                    lightBo.setPoleId(pole.getId());
                                    lightBo.setPoleCode(pole.getDeviceCode());
                                    lightBo.setPoleName(pole.getPoleName());
                            }
                        }
                );
                for (LightReportData lightReportData : reportDataList) {
                    if (StrUtil.equals(lightBo.getDeviceCode(), lightReportData.getDeviceCode())) {
                        lightBo.setReportTime(lightReportData.getCreateTime());
ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleBindingService.java
@@ -5,7 +5,6 @@
import com.sandu.common.service.impl.BaseServiceImpl;
import com.sandu.ximon.admin.param.PoleBindingParam;
import com.sandu.ximon.dao.domain.PoleBinding;
import com.sandu.ximon.dao.enums.PoleBindingEnums;
import com.sandu.ximon.dao.mapper.PoleBindingMapper;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
@@ -86,4 +85,8 @@
            return false;
        }
    }
    public PoleBinding getPoleIdByMac(String deviceCode){
       return getOne(Wrappers.lambdaQuery(PoleBinding.class).eq(PoleBinding::getDeviceCode, deviceCode));
    }
}