From f9f8f90ac63d6ce3274410d3721b173f40db6e41 Mon Sep 17 00:00:00 2001 From: jinpengyong <jpy123456> Date: Fri, 25 Aug 2023 14:12:48 +0800 Subject: [PATCH] chore:过滤海城小时数据 --- screen-manage/src/main/java/com/moral/api/controller/SpecialDeviceController.java | 96 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 92 insertions(+), 4 deletions(-) diff --git a/screen-manage/src/main/java/com/moral/api/controller/SpecialDeviceController.java b/screen-manage/src/main/java/com/moral/api/controller/SpecialDeviceController.java index d8dad90..ba59779 100644 --- a/screen-manage/src/main/java/com/moral/api/controller/SpecialDeviceController.java +++ b/screen-manage/src/main/java/com/moral/api/controller/SpecialDeviceController.java @@ -1,14 +1,22 @@ package com.moral.api.controller; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; +import com.moral.api.entity.Organization; +import com.moral.api.entity.SpecialDevice; +import com.moral.api.entity.SysDictData; +import com.moral.api.entity.Version; +import com.moral.api.mapper.SysDictDataMapper; +import com.moral.api.service.OrganizationService; import com.moral.api.service.SpecialDeviceService; +import com.moral.api.service.VersionService; +import com.moral.constant.Constants; +import com.moral.constant.ResponseCodeEnum; import com.moral.constant.ResultMessage; import com.moral.util.WebUtils; import io.swagger.annotations.Api; import lombok.extern.slf4j.Slf4j; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; @@ -23,6 +31,15 @@ @Resource private SpecialDeviceService specialDeviceService; + @Resource + private OrganizationService organizationService; + + @Resource + private VersionService versionService; + + @Resource + private SysDictDataMapper sysDictDataMapper; + @RequestMapping(value = "getSpecialDeviceByCondition", method = RequestMethod.GET) @ResponseBody public ResultMessage getSpecialDeviceByCondition(HttpServletRequest request) { @@ -33,4 +50,75 @@ } return ResultMessage.fail(Integer.parseInt(resultMap.get("code").toString()),resultMap.get("msg").toString()); } + + @RequestMapping(value = "insert", method = RequestMethod.POST) + @ResponseBody + public ResultMessage insert(@RequestBody SpecialDevice specialDevice){ + Map<String,Object> resultMap = specialDeviceService.insert(specialDevice); + String msg = resultMap.get("msg").toString(); + int code = Integer.parseInt(resultMap.get("code").toString()); + if (code == 0){ + return ResultMessage.ok(msg); + } + return ResultMessage.fail(Integer.parseInt(resultMap.get("code").toString()),resultMap.get("msg").toString()); + } + + @RequestMapping(value = "update", method = RequestMethod.POST) + @ResponseBody + public ResultMessage update (@RequestBody SpecialDevice specialDevice){ + if (specialDevice.getId() == null) { + return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), + ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); + } + if (specialDevice.getMac() != null) { + //������mac��������������� + QueryWrapper<SpecialDevice> queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("mac", specialDevice.getMac()); + queryWrapper.eq("is_delete",Constants.NOT_DELETE); + if (specialDeviceService.getOne(queryWrapper) != null) { + return ResultMessage.fail(ResponseCodeEnum.MAC_IS_EXIST.getCode(), ResponseCodeEnum.MAC_IS_EXIST.getMsg()); + } + } + if (specialDevice.getOrganizationId() != null) { + //��������������������������� + QueryWrapper<Organization> queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("id", specialDevice.getOrganizationId()); + queryWrapper.eq("is_delete",Constants.NOT_DELETE); + if (ObjectUtils.isEmpty(organizationService.getOne(queryWrapper))) { + return ResultMessage.fail(ResponseCodeEnum.ORGANIZATION_NOT_EXIST.getCode(), ResponseCodeEnum.ORGANIZATION_NOT_EXIST.getMsg()); + } + } + if (specialDevice.getDeviceVersionId() != null) { + //��������������������������� + QueryWrapper<Version> queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("id", specialDevice.getDeviceVersionId()); + queryWrapper.eq("is_delete",Constants.NOT_DELETE); + if (ObjectUtils.isEmpty(versionService.getOne(queryWrapper))) { + return ResultMessage.fail(ResponseCodeEnum.VERSION_NOT_EXIST.getCode(), ResponseCodeEnum.VERSION_NOT_EXIST.getMsg()); + } + } + if (specialDevice.getSpecialType() != null) { + //��������������������������� + QueryWrapper<SysDictData> queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("dict_type_id", 27); + queryWrapper.eq("dataKey", specialDevice.getSpecialType()); + queryWrapper.eq("is_delete",Constants.NOT_DELETE); + if (ObjectUtils.isEmpty(sysDictDataMapper.selectOne(queryWrapper))) { + return ResultMessage.fail(ResponseCodeEnum.DICTDATA_KEY_NOT_EXIST.getCode(), ResponseCodeEnum.DICTDATA_KEY_NOT_EXIST.getMsg()); + } + } + specialDeviceService.update(specialDevice); + return ResultMessage.ok(); + } + + @RequestMapping(value = "delete", method = RequestMethod.POST) + @ResponseBody + public ResultMessage delete(@RequestBody Map map){ + if (map.get("id") == null){ + return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), + ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); + } + specialDeviceService.delete(Integer.parseInt(map.get("id").toString())); + return ResultMessage.ok(); + } } -- Gitblit v1.8.0