rk
10 小时以前 7666113e060747cce6be99e0deb68485b4283161
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
package com.doumee.cloud.web.cabinet;
 
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.doumee.api.BaseController;
import com.doumee.config.annotation.LoginNoRequired;
import com.doumee.core.annotation.trace.Trace;
import com.doumee.core.haikang.model.HKConstants;
import com.doumee.core.utils.Constants;
import com.doumee.dao.business.JkVersionMapper;
import com.doumee.dao.business.dto.CloseGridDTO;
import com.doumee.dao.business.dto.GetDriverGridDTO;
import com.doumee.dao.business.dto.OpenGridDriverDTO;
import com.doumee.dao.business.dto.OptGridDTO;
import com.doumee.dao.business.model.InterfaceLog;
import com.doumee.dao.business.model.JkCabinetGrid;
import com.doumee.dao.business.model.JkVersion;
import com.doumee.dao.business.vo.AdminCabinetVO;
import com.doumee.dao.business.vo.CabinetDetailVO;
import com.doumee.dao.business.vo.CabinetFaceVO;
import com.doumee.dao.business.vo.CabinetInfoVO;
import com.doumee.dao.web.response.DriverHomeVO;
import com.doumee.service.business.*;
import com.doumee.service.business.third.model.ApiResponse;
import com.hikvision.artemis.sdk.config.ArtemisConfig;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
/**
 * Created by IntelliJ IDEA.
 *
 * @Author : Rk
 * @create 2025/10/15 9:10
 */
@Api(tags = "【钥匙柜】钥匙柜业务")
@Trace(exclude = true)
@RestController
@RequestMapping(Constants.CLOUD_SERVICE_URL_INDEX+"/web/cabinet")
@Slf4j
public class CabinetController extends BaseController {
 
    @Autowired
    private JkCabinetService jkCabinetService;
 
    @Autowired
    private JkCabinetGridService jkCabinetGridService;
 
    @Autowired
    private InterfaceLogService interfaceLogService;
 
    @Autowired
    private JkIccardService jkIccardService;
 
    @Autowired
    private JkVersionService jkVersionService;
 
    @LoginNoRequired
    @ApiOperation("获取钥匙柜APK最新版本")
    @GetMapping("/getLastVersion")
    public ApiResponse<JkVersion> getLastVersion () {
        JkVersion jkVersion = jkVersionService.getLastVersion();
        this.saveInterfaceLog(null, JSONObject.toJSONString(jkVersion),"getLastVersion","获取钥匙柜APK最新版本");
        return ApiResponse.success(jkVersion);
    }
 
    @LoginNoRequired
    @ApiOperation("获取钥匙柜基本信息 - 司机")
    @GetMapping("/getCabinetInfoForDriver")
    public ApiResponse<CabinetInfoVO> getCabinetInfoForDriver (@RequestParam String code) {
        CabinetInfoVO cabinetInfoVO = jkCabinetService.getCabinetInfoForDriver(code);
        this.saveInterfaceLog(Constants.strToJson("code",code), JSONObject.toJSONString(cabinetInfoVO),"getCabinetInfoForDriver","获取钥匙柜基本信息 - 司机");
        return ApiResponse.success(cabinetInfoVO);
    }
 
    @LoginNoRequired
    @ApiOperation("更新钥匙柜在线状态")
    @GetMapping("/updateRunStatusById")
    public ApiResponse updateRunStatusById (@RequestParam Integer id) {
        jkCabinetService.updateRunStatusById(id);
        this.saveInterfaceLog(Constants.strToJson("id",id.toString()), null,"updateRunStatusById","更新钥匙柜在线状态");
        return ApiResponse.success("更新成功");
    }
 
 
 
    @ApiOperation("获取可管理的钥匙柜列表 - 管理员")
    @GetMapping("/getAdminCabinetInfo")
    public ApiResponse<List<AdminCabinetVO>> getAdminCabinetInfo (@RequestHeader(Constants.HEADER_USER_TOKEN) String token) {
        List<AdminCabinetVO> list = jkCabinetService.getAdminCabinetInfo(getLoginUser(token));
        this.saveInterfaceLog(null, JSONArray.toJSONString(list),"getAdminCabinetInfo","获取可管理的钥匙柜列表 - 管理员");
        return ApiResponse.success(list);
    }
 
 
    @ApiOperation("获取钥匙柜详情 - 管理员")
    @GetMapping("/getCabinetDetail")
    public ApiResponse<CabinetDetailVO> getCabinetDetail (@RequestParam Integer cabinetId, @RequestHeader(Constants.HEADER_USER_TOKEN) String token) {
        CabinetDetailVO cabinetDetailVO = jkCabinetService.getCabinetDetail(cabinetId,getLoginUser(token));
        this.saveInterfaceLog(Constants.strToJson("cabinetId",cabinetId.toString()), JSONObject.toJSONString(cabinetDetailVO),"getCabinetDetail","获取钥匙柜详情 - 管理员");
        return ApiResponse.success(cabinetDetailVO);
    }
 
    @ApiOperation("标记柜格故障 - 管理员")
    @PostMapping("/markFault")
    public ApiResponse markFault(@RequestBody OptGridDTO dto, @RequestHeader(Constants.HEADER_USER_TOKEN) String token) {
        dto.setLoginUserInfo(getLoginUser(token));
        jkCabinetGridService.markFault(dto);
        this.saveInterfaceLog(JSONObject.toJSONString(dto), null,"markFault","标记柜格故障 - 管理员");
        return ApiResponse.success("操作成功");
    }
 
    @ApiOperation("标记柜格正常 - 管理员")
    @PostMapping("/cancelFault")
    public ApiResponse cancelFault(@RequestBody OptGridDTO dto, @RequestHeader(Constants.HEADER_USER_TOKEN) String token) {
        dto.setLoginUserInfo(getLoginUser(token));
        jkCabinetGridService.cancelFault(dto);
        this.saveInterfaceLog(JSONObject.toJSONString(dto), null,"cancelFault","标记柜格正常 - 管理员");
        return ApiResponse.success("操作成功");
    }
 
    @ApiOperation("标记维修保养 - 管理员")
    @PostMapping("/markRepair")
    public ApiResponse markRepair(@RequestBody OptGridDTO dto, @RequestHeader(Constants.HEADER_USER_TOKEN) String token) {
        dto.setLoginUserInfo(getLoginUser(token));
        jkCabinetGridService.markRepair(dto);
        this.saveInterfaceLog(JSONObject.toJSONString(dto), null,"markRepair","标记维修保养 - 管理员");
        return ApiResponse.success("操作成功");
    }
 
    @ApiOperation("关闭柜门")
    @PostMapping("/closeGrid")
    public ApiResponse closeGrid(@RequestBody CloseGridDTO dto) {
        jkCabinetGridService.closeGrid(dto);
        this.saveInterfaceLog(JSONObject.toJSONString(dto), null,"closeGrid","关闭柜门");
        return ApiResponse.success("操作成功");
    }
 
    @ApiOperation("批量开门 - 管理员")
    @PostMapping("/batchOpenGridAdmin")
    public ApiResponse batchOpenGridAdmin(@RequestBody OptGridDTO dto, @RequestHeader(Constants.HEADER_USER_TOKEN) String token) {
        dto.setLoginUserInfo(getLoginUser(token));
        jkCabinetGridService.batchOpenGridAdmin(dto);
        this.saveInterfaceLog(JSONObject.toJSONString(dto), null,"batchOpenGridAdmin","批量开门 - 管理员");
        return ApiResponse.success("操作成功");
    }
 
 
    @ApiOperation("获取钥匙柜人脸数据")
    @GetMapping("/getCabinetFaceVO")
    public ApiResponse<CabinetFaceVO> getCabinetFaceVO(@RequestParam String code) {
        CabinetFaceVO cabinetFaceVO = jkCabinetService.getCabinetFaceVO(code);
        this.saveInterfaceLog(Constants.strToJson("code",code), JSONObject.toJSONString(cabinetFaceVO),"getCabinetFaceVO","获取钥匙柜人脸数据");
        return ApiResponse.success(cabinetFaceVO);
    }
 
 
 
    @ApiOperation("获取可操作柜格 - 司机")
    @PostMapping("/getDriverGrid")
    public ApiResponse<List<JkCabinetGrid>> getDriverGrid(@RequestBody GetDriverGridDTO dto) {
        List<JkCabinetGrid> jkCabinetGridList = jkCabinetGridService.getDriverGrid(dto);
        this.saveInterfaceLog(JSONObject.toJSONString(dto), JSONObject.toJSONString(jkCabinetGridList),"getDriverGrid","获取可操作柜格 - 司机");
        return ApiResponse.success(jkCabinetGridList);
    }
 
    @ApiOperation("开启柜格 - 司机")
    @PostMapping("/openGridDriver")
    public ApiResponse openGridDriver(@RequestBody OpenGridDriverDTO dto) {
        jkCabinetGridService.openGridDriver(dto);
        this.saveInterfaceLog(JSONObject.toJSONString(dto), null,"openGridDriver","开启柜格 - 司机");
        return ApiResponse.success("操作成功");
    }
 
    @ApiOperation("获取IC卡用户主键 - 司机")
    @PostMapping("/getMemberIdByCode")
    public ApiResponse<Integer> getMemberIdByCode(@RequestParam String code) {
        this.saveInterfaceLog(Constants.strToJson("code",code), null,"getMemberIdByCode","获取IC卡用户主键 - 司机");
        return ApiResponse.success(jkIccardService.getMemberIdByCode(code));
    }
 
    private void saveInterfaceLog(String s, String result,String url,String name) {
        InterfaceLog hkMonitoryLogDO=new InterfaceLog();
        hkMonitoryLogDO.setType(0);
        hkMonitoryLogDO.setCreateDate(new Date());
        hkMonitoryLogDO.setIsdeleted(0);
        hkMonitoryLogDO.setRequest(s);
        hkMonitoryLogDO.setRepose(result);
        hkMonitoryLogDO.setName("【钥匙柜】"+name);
        hkMonitoryLogDO.setUrl(url);
        interfaceLogService.create(hkMonitoryLogDO);
    }
 
 
}