bug修复
This commit is contained in:
parent
57f8d61700
commit
fdab6f8123
@ -1,27 +1,23 @@
|
||||
package com.zhgd.xmgl.modules.rt.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.gexin.fastjson.JSON;
|
||||
import com.zhgd.jeecg.common.api.vo.Result;
|
||||
import com.zhgd.xmgl.modules.rt.entity.RtTool;
|
||||
import com.zhgd.xmgl.modules.rt.service.IRtToolService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.zhgd.jeecg.common.api.vo.Result;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
|
||||
import org.simpleframework.xml.core.Validate;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.simpleframework.xml.core.Validate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
@ -36,104 +32,114 @@ import org.springframework.web.bind.annotation.*;
|
||||
@Slf4j
|
||||
@Api(tags = "榕图-工器具相关Api")
|
||||
public class RtToolController {
|
||||
@Autowired
|
||||
private IRtToolService rtToolService;
|
||||
@Autowired
|
||||
private IRtToolService rtToolService;
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "分页列表查询榕图-工器具信息", notes = "分页列表查询榕图-工器具信息", httpMethod = "GET")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "pageNo", value = "第几页", paramType = "query", required = true, dataType = "Integer"),
|
||||
@ApiImplicitParam(name = "pageSize", value = "每页显示条数", paramType = "query", required = true, dataType = "Integer"),
|
||||
})
|
||||
@GetMapping(value = "/page")
|
||||
public Result<IPage<RtTool>> queryPageList(@ApiIgnore @RequestParam HashMap<String, Object> paramMap) {
|
||||
return Result.success(rtToolService.queryPageList(paramMap));
|
||||
}
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "分页列表查询榕图-工器具信息", notes = "分页列表查询榕图-工器具信息", httpMethod = "GET")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "pageNo", value = "第几页", paramType = "query", required = true, dataType = "Integer"),
|
||||
@ApiImplicitParam(name = "pageSize", value = "每页显示条数", paramType = "query", required = true, dataType = "Integer"),
|
||||
})
|
||||
@GetMapping(value = "/page")
|
||||
public Result<IPage<RtTool>> queryPageList(@ApiIgnore @RequestParam HashMap<String, Object> paramMap) {
|
||||
return Result.success(rtToolService.queryPageList(paramMap));
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表查询
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "列表查询榕图-工器具信息", notes = "列表查询榕图-工器具信息", httpMethod = "GET")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<List<RtTool>> queryList(@ApiIgnore @RequestParam HashMap<String, Object> paramMap) {
|
||||
return Result.success(rtToolService.queryList(paramMap));
|
||||
}
|
||||
/**
|
||||
* 列表查询
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "列表查询榕图-工器具信息", notes = "列表查询榕图-工器具信息", httpMethod = "GET")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<List<RtTool>> queryList(@ApiIgnore @RequestParam HashMap<String, Object> paramMap) {
|
||||
return Result.success(rtToolService.queryList(paramMap));
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @param rtTool
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "添加榕图-工器具信息", notes = "添加榕图-工器具信息", httpMethod = "POST")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<RtTool> add(@RequestBody @Validate RtTool rtTool) {
|
||||
rtToolService.add(rtTool);
|
||||
return Result.ok();
|
||||
}
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @param rtTool
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "添加榕图-工器具信息", notes = "添加榕图-工器具信息", httpMethod = "POST")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<RtTool> add(@RequestBody @Validate RtTool rtTool) {
|
||||
rtToolService.add(rtTool);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param rtTool
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "编辑榕图-工器具信息", notes = "编辑榕图-工器具信息", httpMethod = "POST")
|
||||
@PostMapping(value = "/edit")
|
||||
public Result<RtTool> edit(@RequestBody RtTool rtTool) {
|
||||
rtToolService.edit(rtTool);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "删除榕图-工器具信息", notes = "删除榕图-工器具信息", httpMethod = "POST")
|
||||
@ApiImplicitParam(name = "id", value = "榕图-工器具ID", paramType = "body", required = true, dataType = "String", example = "{\"id\":\"1\"}")
|
||||
@PostMapping(value = "/delete")
|
||||
public Result<RtTool> delete(@ApiIgnore @RequestBody HashMap<String, Object> map) {
|
||||
String id = MapUtils.getString(map, "id");
|
||||
Result<RtTool> result = new Result<RtTool>();
|
||||
RtTool rtTool = rtToolService.getById(id);
|
||||
if (rtTool == null) {
|
||||
result.error500("未找到对应实体");
|
||||
} else {
|
||||
boolean ok = rtToolService.removeById(id);
|
||||
if (ok) {
|
||||
result.success("删除成功!");
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param rtTool
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "编辑榕图-工器具信息", notes = "编辑榕图-工器具信息", httpMethod = "POST")
|
||||
@PostMapping(value = "/edit")
|
||||
public Result<RtTool> edit(@RequestBody RtTool rtTool) {
|
||||
rtToolService.edit(rtTool);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
@ApiOperation(value = "更新榕图-工器具状态", notes = "更新榕图-工器具状态", httpMethod = "POST")
|
||||
@PostMapping(value = "/updateRtToolStatus")
|
||||
public Result<RtTool> updateRtToolStatus(@RequestBody RtTool rtTool) {
|
||||
log.info("更新榕图-工器具状态:{}", JSON.toJSONString(rtTool));
|
||||
rtToolService.updateRtToolStatus(rtTool);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "通过id查询榕图-工器具信息", notes = "通过id查询榕图-工器具信息", httpMethod = "GET")
|
||||
@ApiImplicitParam(name = "id", value = "榕图-工器具ID", paramType = "query", required = true, dataType = "Integer")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<RtTool> queryById(@RequestParam(name = "id", required = true) String id) {
|
||||
Result<RtTool> result = new Result<RtTool>();
|
||||
RtTool rtTool = rtToolService.getById(id);
|
||||
if (rtTool == null) {
|
||||
result.error500("未找到对应实体");
|
||||
} else {
|
||||
result.setResult(rtTool);
|
||||
result.setSuccess(true);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "删除榕图-工器具信息", notes = "删除榕图-工器具信息", httpMethod = "POST")
|
||||
@ApiImplicitParam(name = "id", value = "榕图-工器具ID", paramType = "body", required = true, dataType = "String", example = "{\"id\":\"1\"}")
|
||||
@PostMapping(value = "/delete")
|
||||
public Result<RtTool> delete(@ApiIgnore @RequestBody HashMap<String, Object> map) {
|
||||
String id = MapUtils.getString(map, "id");
|
||||
Result<RtTool> result = new Result<RtTool>();
|
||||
RtTool rtTool = rtToolService.getById(id);
|
||||
if (rtTool == null) {
|
||||
result.error500("未找到对应实体");
|
||||
} else {
|
||||
boolean ok = rtToolService.removeById(id);
|
||||
if (ok) {
|
||||
result.success("删除成功!");
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "通过id查询榕图-工器具信息", notes = "通过id查询榕图-工器具信息", httpMethod = "GET")
|
||||
@ApiImplicitParam(name = "id", value = "榕图-工器具ID", paramType = "query", required = true, dataType = "Integer")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<RtTool> queryById(@RequestParam(name = "id", required = true) String id) {
|
||||
Result<RtTool> result = new Result<RtTool>();
|
||||
RtTool rtTool = rtToolService.getById(id);
|
||||
if (rtTool == null) {
|
||||
result.error500("未找到对应实体");
|
||||
} else {
|
||||
result.setResult(rtTool);
|
||||
result.setSuccess(true);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -22,4 +22,6 @@ public interface IRtToolService extends IService<RtTool> {
|
||||
void add(RtTool rtTool);
|
||||
|
||||
void edit(RtTool rtTool);
|
||||
|
||||
void updateRtToolStatus(RtTool rtTool);
|
||||
}
|
||||
|
||||
@ -1,25 +1,27 @@
|
||||
package com.zhgd.xmgl.modules.rt.service.impl;
|
||||
|
||||
import com.zhgd.xmgl.modules.rt.entity.RtTool;
|
||||
import com.zhgd.xmgl.modules.rt.mapper.RtToolMapper;
|
||||
import com.zhgd.xmgl.modules.rt.service.IRtToolService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.zhgd.jeecg.common.system.query.QueryGenerator;
|
||||
import com.zhgd.xmgl.util.PageUtil;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zhgd.jeecg.common.execption.OpenAlertException;
|
||||
import com.zhgd.jeecg.common.system.query.QueryGenerator;
|
||||
import com.zhgd.xmgl.modules.rt.entity.RtTool;
|
||||
import com.zhgd.xmgl.modules.rt.mapper.RtToolMapper;
|
||||
import com.zhgd.xmgl.modules.rt.service.IRtToolService;
|
||||
import com.zhgd.xmgl.util.PageUtil;
|
||||
import com.zhgd.xmgl.util.RefUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import com.zhgd.xmgl.util.RefUtil;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
* @Description: 榕图-工器具
|
||||
* @author: pds
|
||||
@ -60,6 +62,12 @@ public class RtToolServiceImpl extends ServiceImpl<RtToolMapper, RtTool> impleme
|
||||
|
||||
@Override
|
||||
public void add(RtTool rtTool) {
|
||||
List<RtTool> rtTools = rtToolMapper.selectList(new LambdaQueryWrapper<RtTool>()
|
||||
.eq(RtTool::getDevSn, rtTool.getDevSn())
|
||||
);
|
||||
if (CollUtil.isNotEmpty(rtTools)) {
|
||||
throw new OpenAlertException("设备编号已存在");
|
||||
}
|
||||
setExitTimeIf(rtTool);
|
||||
rtTool.setId(null);
|
||||
baseMapper.insert(rtTool);
|
||||
@ -67,13 +75,37 @@ public class RtToolServiceImpl extends ServiceImpl<RtToolMapper, RtTool> impleme
|
||||
|
||||
@Override
|
||||
public void edit(RtTool rtTool) {
|
||||
List<RtTool> rtTools = rtToolMapper.selectList(new LambdaQueryWrapper<RtTool>()
|
||||
.eq(RtTool::getDevSn, rtTool.getDevSn())
|
||||
.ne(RtTool::getId, rtTool.getId())
|
||||
);
|
||||
if (CollUtil.isNotEmpty(rtTools)) {
|
||||
throw new OpenAlertException("设备编号已存在");
|
||||
}
|
||||
setExitTimeIf(rtTool);
|
||||
baseMapper.updateById(rtTool);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateRtToolStatus(RtTool rtTool) {
|
||||
RtTool t = rtToolMapper.selectOne(new LambdaQueryWrapper<RtTool>()
|
||||
.eq(RtTool::getDevSn, rtTool.getDevSn()));
|
||||
if (t == null) {
|
||||
throw new OpenAlertException("设备编号不正确");
|
||||
}
|
||||
Integer toolStatus = rtTool.getToolStatus();
|
||||
if (!(Objects.equals(toolStatus, 1) || Objects.equals(toolStatus, 2))) {
|
||||
throw new OpenAlertException("toolStatus的值必须为1或2");
|
||||
}
|
||||
setExitTimeIf(rtTool);
|
||||
baseMapper.update(rtTool, new LambdaQueryWrapper<RtTool>()
|
||||
.eq(RtTool::getDevSn, rtTool.getDevSn()));
|
||||
}
|
||||
|
||||
private void setExitTimeIf(RtTool rtTool) {
|
||||
if (Objects.equals(rtTool.getToolStatus(), 2)) {
|
||||
rtTool.setExitTime(new Date());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -274,6 +274,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
.antMatchers("/service-address/workers").permitAll()
|
||||
.antMatchers("/service-address/photo").permitAll()
|
||||
.antMatchers("/xmgl/sewageData/add").permitAll()
|
||||
.antMatchers("/xmgl/rtTool/updateRtToolStatus").permitAll()
|
||||
.antMatchers(HttpMethod.OPTIONS, "/**").anonymous()
|
||||
.anyRequest().authenticated() // 剩下所有的验证都需要验证
|
||||
.and()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user