2021与蓝度共同重构项目,服务端
fix
zhanzhiqin
2022-05-07 8c46bedb1a637ba04bd406dab7bba889e1d5d658
ximon-admin/src/main/java/com/sandu/ximon/admin/controller/PoleController.java
@@ -7,6 +7,7 @@
import com.sandu.common.domain.CommonPage;
import com.sandu.common.domain.ResponseVO;
import com.sandu.common.object.BaseConditionVO;
import com.sandu.common.security.annotation.AnonymousAccess;
import com.sandu.common.util.ResponseUtil;
import com.sandu.ximon.admin.dto.DeviceStatus;
import com.sandu.ximon.admin.param.PoleBindParam;
@@ -24,7 +25,6 @@
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.sql.Wrapper;
import java.util.List;
/**
@@ -87,6 +87,7 @@
    /**
     * 在线数量
     */
    @AnonymousAccess
    @GetMapping("/online")
    public ResponseVO<Object> online() {
        return ResponseUtil.success(poleService.poleCount());
@@ -120,11 +121,11 @@
    public ResponseVO<Object> bindPole(@PathVariable Long poleId, @RequestBody @Validated PoleBindingParam param) {
        boolean result = poleService.bindPole(poleId, param);
        if (result) {
            //设备类型,0路灯,1nove,2充电桩,3大气监测,4水质监测,5ip音柱,6lcd广告机,7摄像头,8杆体倾测,9一键救助, 10熙讯
            //设备类型,0路灯,1nove,2充电桩,3大气监测,4水质监测,5ip音柱,6lcd广告机,7摄像头,8杆体倾测,9一键救助, 10熙讯, 11农耕
            switch (param.getDeviceType()) {
                case 0:
                    Pole pole = poleService.getById(poleId);
                    if (!pole.getDeviceCode().equals(param.getDeviceCode())) {
                    if (pole != null) {
                        pole.setPoleName(param.getDeviceName());
                        pole.setDeviceCode(param.getDeviceCode());
                        poleService.updateById(pole);
@@ -152,6 +153,8 @@
                    break;
                case 10:
                    break;
                case 11:
                    break;
                default:
                    break;
            }
@@ -169,9 +172,14 @@
    public ResponseVO<Object> unBindPole(@PathVariable Long poleId, @RequestBody @Validated PoleBindingParam param) {
        boolean result = poleService.unBindPole(poleId, param.getDeviceCode());
        if (result) {
            //设备类型,0路灯,1led屏幕,2充电桩,3大气监测,4水质监测,5ip音柱,6lcd广告机,7摄像头,8杆体倾测,9一键救助
            //设备类型,0路灯,1led屏幕,2充电桩,3大气监测,4水质监测,5ip音柱,6lcd广告机,7摄像头,8杆体倾测,9一键救助, 10熙讯, 11农耕
            switch (param.getDeviceType()) {
                case 0:
                    //删除灯杆的devicescode
                    Pole pole = poleService.getOne(Wrappers.lambdaQuery(Pole.class).eq(Pole::getId, poleId));
                    if (pole != null) {
                        poleService.updateDeviceCode(pole.getId());
                    }
                    break;
                case 1:
                    break;
@@ -194,6 +202,8 @@
                case 9:
                    break;
                case 10:
                    break;
                case 11:
                    break;
                default:
                    break;
@@ -233,24 +243,35 @@
    public ResponseVO<Object> getOwnerPole(BaseConditionVO baseConditionVO, @RequestParam(value = "keyword", required = false) String keyword
            , @PathVariable Long cilentId) {
        List<Pole> results = poleService.getOwnerPole(baseConditionVO, keyword, cilentId);
//        CommonPage commonPage = CommonPage.restPage(results);
//        int size = results.size();
//        commonPage.setTotal((long) size);
//        commonPage.setTotalPage(size / baseConditionVO.getPageSize() + 1);
//        if (size % baseConditionVO.getPageSize() == 0) {
//            commonPage.setTotalPage(size / baseConditionVO.getPageSize());
//        }
//        return ResponseUtil.success(commonPage);
        return ResponseUtil.success(results);
    }
    /**
     * 查看灯杆绑定的设备
     */
    @AnonymousAccess
    @PostMapping("/getPoleBindDevice/{poleId}")
    public ResponseVO<Object> getPoleBindDevice(@PathVariable Long poleId) {
        return ResponseUtil.success(poleService.getBindByPoleId(poleId));
    }
    /**
     * 推送大气设备到诺瓦
     */
    @AnonymousAccess
    @GetMapping("/pushAidDataToNova/{poleId}")
    public ResponseVO<Object> pushAirDataToNova(@PathVariable Long poleId) {
        return ResponseUtil.success(poleService.pushAirDataToNova(poleId));
    }
    /**
     * 推送大气设备到熙讯
     */
    @AnonymousAccess
    @GetMapping("/pushAirDataToXiXun/{poleId}")
    public ResponseVO<Object> pushAirDataToXiXun(@PathVariable Long poleId) {
        return ResponseUtil.success(poleService.pushAirDataToXiXun(poleId));
    }
}