jialh
2 天以前 dd6687b118561100e1677e88a9c2f5842a54c531
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
45
46
47
48
49
package com.java110.api.smo.impl;
 
import com.alibaba.fastjson.JSONObject;
import com.java110.api.websocket.ParkingAreaWebsocket;
import com.java110.api.websocket.ParkingBoxWebsocket;
import com.java110.dto.parking.ParkingBoxAreaDto;
import com.java110.intf.api.IApiCallBackInnerServiceSMO;
import com.java110.intf.community.IParkingBoxAreaV1InnerServiceSMO;
import com.java110.utils.exception.SMOException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
 
import java.util.List;
 
@RestController
public class ApiCallBackInnerServiceSMOImpl implements IApiCallBackInnerServiceSMO {
 
    @Autowired
    private IParkingBoxAreaV1InnerServiceSMO parkingBoxAreaV1InnerServiceSMOImpl;
 
    @Override
    public int webSentParkingArea(@RequestBody JSONObject reqJson) {
        JSONObject param = JSONObject.parseObject(reqJson.toString());
        try {
            ParkingBoxWebsocket.sendInfo(param.toJSONString(), param.getString("extBoxId"));
 
        } catch (Exception e) {
            throw new SMOException(e.getMessage());
        }
 
        ParkingBoxAreaDto parkingBoxAreaDto = new ParkingBoxAreaDto();
        parkingBoxAreaDto.setBoxId(reqJson.getString("extBoxId"));
        parkingBoxAreaDto.setDefaultArea(ParkingBoxAreaDto.DEFAULT_AREA_TRUE);
 
        List<ParkingBoxAreaDto> parkingBoxAreaDtos = parkingBoxAreaV1InnerServiceSMOImpl.queryParkingBoxAreas(parkingBoxAreaDto);
 
        if(parkingBoxAreaDtos == null || parkingBoxAreaDtos.size()<1){
            return 1;
        }
 
        try {
            ParkingAreaWebsocket.sendInfo(param.toJSONString(), parkingBoxAreaDtos.get(0).getPaId());
        } catch (Exception e) {
            throw new SMOException(e.getMessage());
        }
        return 1;
    }
}