2021与蓝度共同重构项目,服务端
fix
zhanzhiqin
2021-12-27 d9035580bfaa4d8ad0f6060f4cd6a58ebc452df7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package com.sandu.ximon.admin.service;
 
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.sandu.common.execption.BusinessException;
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;
 
/**
 * @author chenjiantian
 * @date 2021/12/14 11:48
 */
@Service
@AllArgsConstructor
public class PoleBindingService extends BaseServiceImpl<PoleBindingMapper, PoleBinding> {
 
    private final LightReportDataService lightReportDataService;
 
    public boolean bindPole(Long poleId, PoleBindingParam param) {
        Integer deviceType = param.getDeviceType();
//        if (PoleBindingEnums.LIGHT.getCode().equals(deviceType)) {
//        }
 
        PoleBinding one = getOne(Wrappers.lambdaQuery(PoleBinding.class).eq(PoleBinding::getDeviceCode, param.getDeviceCode()));
        if (one == null) {
            PoleBinding poleBinding = new PoleBinding();
            poleBinding.setPoleId(poleId);
            poleBinding.setDeviceType(deviceType);
            poleBinding.setDeviceName(param.getDeviceName());
            poleBinding.setDeviceCode(param.getDeviceCode());
            return save(poleBinding);
        } else {
            throw new BusinessException("该设备已绑定过");
        }
 
 
//        return false;
 
    }
}