|
|
|
@ -45,89 +45,85 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
|
|
|
|
|
@Slf4j |
|
|
|
|
@AllArgsConstructor |
|
|
|
|
@RequestMapping("/accident") |
|
|
|
|
@Api(value = "事故管理",tags = "事故管理") |
|
|
|
|
@Api(value = "事故管理", tags = "事故管理") |
|
|
|
|
public class AccidentController extends BladeController { |
|
|
|
|
|
|
|
|
|
private final IAccidentService accidentService; |
|
|
|
|
private final IOssClient ossClient; |
|
|
|
|
private static ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); |
|
|
|
|
private static ReentrantReadWriteLock.WriteLock writeLock = lock.writeLock(); |
|
|
|
|
private static ReentrantReadWriteLock.ReadLock readLock = lock.readLock(); |
|
|
|
|
private final IAccidentService accidentService; |
|
|
|
|
private final IOssClient ossClient; |
|
|
|
|
private static ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); |
|
|
|
|
private static ReentrantReadWriteLock.WriteLock writeLock = lock.writeLock(); |
|
|
|
|
private static ReentrantReadWriteLock.ReadLock readLock = lock.readLock(); |
|
|
|
|
|
|
|
|
|
@PostMapping("/save") |
|
|
|
|
@ApiOperation("事故管理保存") |
|
|
|
|
@ApiOperationSupport(order = 1) |
|
|
|
|
public R save(@RequestBody @Valid AccidentDTO req) { |
|
|
|
|
AccidentEntity accidentEntity = BeanUtil.copy(req,AccidentEntity.class); |
|
|
|
|
accidentService.save(accidentEntity); |
|
|
|
|
return R.data(accidentEntity); |
|
|
|
|
} |
|
|
|
|
@PostMapping("/save") |
|
|
|
|
@ApiOperation("事故管理保存") |
|
|
|
|
@ApiOperationSupport(order = 1) |
|
|
|
|
public R save(@RequestBody @Valid AccidentDTO req) { |
|
|
|
|
AccidentEntity accidentEntity = BeanUtil.copy(req, AccidentEntity.class); |
|
|
|
|
accidentService.save(accidentEntity); |
|
|
|
|
return R.data(accidentEntity); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@GetMapping("/detail/{id}") |
|
|
|
|
@ApiOperation("事故管理查询详情") |
|
|
|
|
@ApiOperationSupport(order = 2) |
|
|
|
|
public R<AccidentVO> detail(@PathVariable(value = "id") Long id) { |
|
|
|
|
AccidentVO accidentVO = null; |
|
|
|
|
readLock.lock(); |
|
|
|
|
try{ |
|
|
|
|
AccidentEntity accidentEntity = accidentService.getById(id); |
|
|
|
|
if( ObjectUtil.isNotEmpty(accidentEntity)) { |
|
|
|
|
accidentVO = AccidentWrapper.build().entityVO(accidentEntity); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
catch(Exception e){ |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
} |
|
|
|
|
finally { |
|
|
|
|
readLock.unlock(); |
|
|
|
|
} |
|
|
|
|
return R.data(accidentVO); |
|
|
|
|
} |
|
|
|
|
@GetMapping("/detail/{id}") |
|
|
|
|
@ApiOperation("事故管理查询详情") |
|
|
|
|
@ApiOperationSupport(order = 2) |
|
|
|
|
public R<AccidentVO> detail(@PathVariable(value = "id") Long id) { |
|
|
|
|
AccidentVO accidentVO = null; |
|
|
|
|
readLock.lock(); |
|
|
|
|
try { |
|
|
|
|
AccidentEntity accidentEntity = accidentService.getById(id); |
|
|
|
|
if (ObjectUtil.isNotEmpty(accidentEntity)) { |
|
|
|
|
accidentVO = AccidentWrapper.build().entityVO(accidentEntity); |
|
|
|
|
} |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
} finally { |
|
|
|
|
readLock.unlock(); |
|
|
|
|
} |
|
|
|
|
return R.data(accidentVO); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@PostMapping("updateById") |
|
|
|
|
@ApiOperation("根据ID修改事故") |
|
|
|
|
@ApiOperationSupport(order = 3) |
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
public R updateById (@RequestBody @Valid AccidentDTO req) { |
|
|
|
|
writeLock.lock(); |
|
|
|
|
try{ |
|
|
|
|
AccidentEntity accidentEntity = BeanUtil.copy(req,AccidentEntity.class); |
|
|
|
|
accidentService.updateById(accidentEntity); |
|
|
|
|
} |
|
|
|
|
catch(Exception e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
} |
|
|
|
|
finally { |
|
|
|
|
writeLock.unlock(); |
|
|
|
|
} |
|
|
|
|
return R.success("操作成功"); |
|
|
|
|
} |
|
|
|
|
@PostMapping("updateById") |
|
|
|
|
@ApiOperation("根据ID修改事故") |
|
|
|
|
@ApiOperationSupport(order = 3) |
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
public R updateById(@RequestBody @Valid AccidentDTO req) { |
|
|
|
|
writeLock.lock(); |
|
|
|
|
try { |
|
|
|
|
AccidentEntity accidentEntity = BeanUtil.copy(req, AccidentEntity.class); |
|
|
|
|
accidentService.updateById(accidentEntity); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
} finally { |
|
|
|
|
writeLock.unlock(); |
|
|
|
|
} |
|
|
|
|
return R.success("操作成功"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@PutMapping("/remove/{ids}") |
|
|
|
|
@ApiOperation("删除事故管理,id按逗号分隔") |
|
|
|
|
@ApiOperationSupport(order = 4) |
|
|
|
|
public R remove(@PathVariable(value = "ids") @Valid String ids) { |
|
|
|
|
List<Long> idList = Func.toLongList(ids); |
|
|
|
|
return R.status(accidentService.deleteLogic(idList)); |
|
|
|
|
} |
|
|
|
|
@PutMapping("/remove/{ids}") |
|
|
|
|
@ApiOperation("删除事故管理,id按逗号分隔") |
|
|
|
|
@ApiOperationSupport(order = 4) |
|
|
|
|
public R remove(@PathVariable(value = "ids") @Valid String ids) { |
|
|
|
|
List<Long> idList = Func.toLongList(ids); |
|
|
|
|
return R.status(accidentService.deleteLogic(idList)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ApiLog |
|
|
|
|
@GetMapping("/pageList") |
|
|
|
|
@ApiOperation("分页查询") |
|
|
|
|
@ApiOperationSupport(order = 5) |
|
|
|
|
@OperationAnnotation(moduleName = "安全管理", |
|
|
|
|
title = "事故管理",operatorType = OperatorType.MOBILE,businessType = BusinessType.GENCODE, |
|
|
|
|
action = "分页条件") |
|
|
|
|
public R<IPage> pageList(AccidentDTO req, Query query){ |
|
|
|
|
AccidentEntity accidentEntity = BeanUtil.copy(req,AccidentEntity.class); |
|
|
|
|
LambdaQueryWrapper<AccidentEntity> queryWrapper = Condition.getQueryWrapper(new AccidentEntity(),accidentEntity); |
|
|
|
|
if(ObjectUtil.isNotEmpty(req.getStatus())){ |
|
|
|
|
queryWrapper.eq(AccidentEntity::getStatus,req.getStatus()); |
|
|
|
|
} |
|
|
|
|
IPage page = accidentService.page(Condition.getPage(query),queryWrapper); |
|
|
|
|
if(CollectionUtil.isNotEmpty(page.getRecords())){ |
|
|
|
|
page.setRecords(AccidentWrapper.build().listVO(page.getRecords())); |
|
|
|
|
} |
|
|
|
|
return R.data(page); |
|
|
|
|
} |
|
|
|
|
@ApiLog |
|
|
|
|
@GetMapping("/pageList") |
|
|
|
|
@ApiOperation("分页查询") |
|
|
|
|
@ApiOperationSupport(order = 5) |
|
|
|
|
@OperationAnnotation(moduleName = "安全管理", |
|
|
|
|
title = "事故管理", operatorType = OperatorType.MOBILE, businessType = BusinessType.GENCODE, |
|
|
|
|
action = "分页查询事故管理列表") |
|
|
|
|
public R<IPage> pageList(AccidentDTO req, Query query) { |
|
|
|
|
AccidentEntity accidentEntity = BeanUtil.copy(req, AccidentEntity.class); |
|
|
|
|
LambdaQueryWrapper<AccidentEntity> queryWrapper = Condition.getQueryWrapper(new AccidentEntity(), accidentEntity); |
|
|
|
|
if (ObjectUtil.isNotEmpty(req.getStatus())) { |
|
|
|
|
queryWrapper.eq(AccidentEntity::getStatus, req.getStatus()); |
|
|
|
|
} |
|
|
|
|
IPage page = accidentService.page(Condition.getPage(query), queryWrapper); |
|
|
|
|
if (CollectionUtil.isNotEmpty(page.getRecords())) { |
|
|
|
|
page.setRecords(AccidentWrapper.build().listVO(page.getRecords())); |
|
|
|
|
} |
|
|
|
|
return R.data(page); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|