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