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.*; import com.doumee.dao.business.model.InterfaceLog; import com.doumee.dao.business.model.JkCabinetGrid; import com.doumee.dao.business.model.JkInterfaceLog; 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 JkInterfaceLogService interfaceLogService; @Autowired private JkIccardService jkIccardService; @Autowired private JkVersionService jkVersionService; @LoginNoRequired @ApiOperation("获取钥匙柜APK最新版本") @GetMapping("/getLastVersion") public ApiResponse getLastVersion () { JkVersion jkVersion = jkVersionService.getLastVersion(); this.saveInterfaceLog(null, JSONObject.toJSONString(jkVersion),"getLastVersion","获取钥匙柜APK最新版本"); return ApiResponse.success(jkVersion); } @LoginNoRequired @ApiOperation("获取钥匙柜基本信息 - 司机") @GetMapping("/getCabinetInfoForDriver") public ApiResponse 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> getAdminCabinetInfo (@RequestHeader(Constants.HEADER_USER_TOKEN) String token) { List list = jkCabinetService.getAdminCabinetInfo(getLoginUser(token)); this.saveInterfaceLog(null, JSONArray.toJSONString(list),"getAdminCabinetInfo","获取可管理的钥匙柜列表 - 管理员"); return ApiResponse.success(list); } @ApiOperation("获取钥匙柜详情 - 管理员") @GetMapping("/getCabinetDetail") public ApiResponse 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("操作成功"); } @LoginNoRequired @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("操作成功"); } @LoginNoRequired @ApiOperation("获取钥匙柜人脸数据") @GetMapping("/getCabinetFaceVO") public ApiResponse getCabinetFaceVO(@RequestParam String code) { CabinetFaceVO cabinetFaceVO = jkCabinetService.getCabinetFaceVO(code); this.saveInterfaceLog(Constants.strToJson("code",code), JSONObject.toJSONString(cabinetFaceVO),"getCabinetFaceVO","获取钥匙柜人脸数据"); return ApiResponse.success(cabinetFaceVO); } @LoginNoRequired @ApiOperation("获取可操作柜格 - 司机") @PostMapping("/getDriverGrid") public ApiResponse> getDriverGrid(@RequestBody GetDriverGridDTO dto) { List jkCabinetGridList = jkCabinetGridService.getDriverGrid(dto); this.saveInterfaceLog(JSONObject.toJSONString(dto), JSONObject.toJSONString(jkCabinetGridList),"getDriverGrid","获取可操作柜格 - 司机"); return ApiResponse.success(jkCabinetGridList); } @LoginNoRequired @ApiOperation("开启柜格 - 司机") @PostMapping("/openGridDriver") public ApiResponse openGridDriver(@RequestBody OpenGridDriverDTO dto) { jkCabinetGridService.openGridDriver(dto); this.saveInterfaceLog(JSONObject.toJSONString(dto), null,"openGridDriver","开启柜格 - 司机"); return ApiResponse.success("操作成功"); } @LoginNoRequired @ApiOperation("获取IC卡用户主键 - 司机") @PostMapping("/getMemberIdByCode") public ApiResponse 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) { JkInterfaceLog hkMonitoryLogDO=new JkInterfaceLog(); 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); } @LoginNoRequired @ApiOperation("酒精检测告警") @PostMapping("/alcoholTestAlarm") public ApiResponse alcoholTestAlarm(@RequestBody AlcoholTestAlarmDTO dto) { jkCabinetGridService.alcoholTestAlarm(dto); return ApiResponse.success("操作成功"); } @LoginNoRequired @ApiOperation("柜格开门超时未关闭告警") @PostMapping("/timeOutUnCloseAlarm") public ApiResponse timeOutUnCloseAlarm(@RequestBody TimeOutCloseGridDTO dto) { jkCabinetGridService.timeOutUnCloseAlarm(dto); return ApiResponse.success("操作成功"); } }