|
|
@ -18,6 +18,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import org.jeecg.modules.zydevice.devicemodel.service.IZyDevicemodelService; |
|
|
|
import org.jeecg.modules.zydevice.devicetype.entity.ZyDevicetype; |
|
|
|
import org.jeecg.modules.zydevice.devicetype.entity.ZyDevicetype; |
|
|
|
import org.jeecg.modules.zydevice.devicetype.service.IZyDevicetypeService; |
|
|
|
import org.jeecg.modules.zydevice.devicetype.service.IZyDevicetypeService; |
|
|
|
import org.jeecgframework.poi.excel.ExcelImportUtil; |
|
|
|
import org.jeecgframework.poi.excel.ExcelImportUtil; |
|
|
@ -49,8 +50,10 @@ import org.jeecg.common.aspect.annotation.AutoLog; |
|
|
|
public class ZyDevicetypeController extends JeecgController<ZyDevicetype, IZyDevicetypeService> { |
|
|
|
public class ZyDevicetypeController extends JeecgController<ZyDevicetype, IZyDevicetypeService> { |
|
|
|
@Autowired |
|
|
|
@Autowired |
|
|
|
private IZyDevicetypeService zyDevicetypeService; |
|
|
|
private IZyDevicetypeService zyDevicetypeService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
|
|
private IZyDevicemodelService zyDevicemodelService; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 分页列表查询 |
|
|
|
* 分页列表查询 |
|
|
|
* |
|
|
|
* |
|
|
|
* @param zyDevicetype |
|
|
|
* @param zyDevicetype |
|
|
@ -83,6 +86,9 @@ public class ZyDevicetypeController extends JeecgController<ZyDevicetype, IZyDev |
|
|
|
@ApiOperation(value="设备类型-添加", notes="设备类型-添加") |
|
|
|
@ApiOperation(value="设备类型-添加", notes="设备类型-添加") |
|
|
|
@PostMapping(value = "/add") |
|
|
|
@PostMapping(value = "/add") |
|
|
|
public Result<?> add(@RequestBody ZyDevicetype zyDevicetype) { |
|
|
|
public Result<?> add(@RequestBody ZyDevicetype zyDevicetype) { |
|
|
|
|
|
|
|
if(zyDevicetype.getName().length()>200){ |
|
|
|
|
|
|
|
return Result.error("添加失败,设备类型名称太长!"); |
|
|
|
|
|
|
|
} |
|
|
|
QueryWrapper queryWrapper=new QueryWrapper(); |
|
|
|
QueryWrapper queryWrapper=new QueryWrapper(); |
|
|
|
queryWrapper.eq("name",zyDevicetype.getName()); |
|
|
|
queryWrapper.eq("name",zyDevicetype.getName()); |
|
|
|
int a=zyDevicetypeService.count(queryWrapper); |
|
|
|
int a=zyDevicetypeService.count(queryWrapper); |
|
|
@ -90,7 +96,7 @@ public class ZyDevicetypeController extends JeecgController<ZyDevicetype, IZyDev |
|
|
|
zyDevicetypeService.save(zyDevicetype); |
|
|
|
zyDevicetypeService.save(zyDevicetype); |
|
|
|
return Result.OK("添加成功!");} |
|
|
|
return Result.OK("添加成功!");} |
|
|
|
else{ |
|
|
|
else{ |
|
|
|
return Result.error("添加失败,该设备名称已存在!"); |
|
|
|
return Result.error("添加失败,该设备类型名称已存在!"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -104,6 +110,9 @@ public class ZyDevicetypeController extends JeecgController<ZyDevicetype, IZyDev |
|
|
|
@ApiOperation(value="设备类型-编辑", notes="设备类型-编辑") |
|
|
|
@ApiOperation(value="设备类型-编辑", notes="设备类型-编辑") |
|
|
|
@PutMapping(value = "/edit") |
|
|
|
@PutMapping(value = "/edit") |
|
|
|
public Result<?> edit(@RequestBody ZyDevicetype zyDevicetype) { |
|
|
|
public Result<?> edit(@RequestBody ZyDevicetype zyDevicetype) { |
|
|
|
|
|
|
|
if(zyDevicetype.getName().length()>200){ |
|
|
|
|
|
|
|
return Result.error("添加失败,设备类型名称太长!"); |
|
|
|
|
|
|
|
} |
|
|
|
QueryWrapper queryWrapper=new QueryWrapper(); |
|
|
|
QueryWrapper queryWrapper=new QueryWrapper(); |
|
|
|
queryWrapper.eq("name",zyDevicetype.getName()); |
|
|
|
queryWrapper.eq("name",zyDevicetype.getName()); |
|
|
|
int a=zyDevicetypeService.count(queryWrapper); |
|
|
|
int a=zyDevicetypeService.count(queryWrapper); |
|
|
@ -125,6 +134,14 @@ public class ZyDevicetypeController extends JeecgController<ZyDevicetype, IZyDev |
|
|
|
@ApiOperation(value="设备类型-通过id删除", notes="设备类型-通过id删除") |
|
|
|
@ApiOperation(value="设备类型-通过id删除", notes="设备类型-通过id删除") |
|
|
|
@DeleteMapping(value = "/delete") |
|
|
|
@DeleteMapping(value = "/delete") |
|
|
|
public Result<?> delete(@RequestParam(name="id",required=true) String id) { |
|
|
|
public Result<?> delete(@RequestParam(name="id",required=true) String id) { |
|
|
|
|
|
|
|
ZyDevicetype zyDevicetype = zyDevicetypeService.getById(id); |
|
|
|
|
|
|
|
//判断型号中是否被使用
|
|
|
|
|
|
|
|
QueryWrapper queryWrapper=new QueryWrapper(); |
|
|
|
|
|
|
|
queryWrapper.eq("devicetype_code",zyDevicetype.getCode()); |
|
|
|
|
|
|
|
int a=zyDevicemodelService.count(queryWrapper); |
|
|
|
|
|
|
|
if(a>=1){ |
|
|
|
|
|
|
|
return Result.error("本类型已被使用,请先删除对应型号!!!"); |
|
|
|
|
|
|
|
} |
|
|
|
zyDevicetypeService.removeById(id); |
|
|
|
zyDevicetypeService.removeById(id); |
|
|
|
return Result.OK("删除成功!"); |
|
|
|
return Result.OK("删除成功!"); |
|
|
|
} |
|
|
|
} |
|
|
|