|
|
@ -45,7 +45,7 @@ import java.util.concurrent.locks.ReentrantReadWriteLock; |
|
|
|
@Slf4j |
|
|
|
@Slf4j |
|
|
|
@AllArgsConstructor |
|
|
|
@AllArgsConstructor |
|
|
|
@RequestMapping("/accident") |
|
|
|
@RequestMapping("/accident") |
|
|
|
@Api(value = "事故管理",tags = "事故管理") |
|
|
|
@Api(value = "事故管理", tags = "事故管理") |
|
|
|
public class AccidentController extends BladeController { |
|
|
|
public class AccidentController extends BladeController { |
|
|
|
|
|
|
|
|
|
|
|
private final IAccidentService accidentService; |
|
|
|
private final IAccidentService accidentService; |
|
|
@ -58,7 +58,7 @@ public class AccidentController extends BladeController { |
|
|
|
@ApiOperation("事故管理保存") |
|
|
|
@ApiOperation("事故管理保存") |
|
|
|
@ApiOperationSupport(order = 1) |
|
|
|
@ApiOperationSupport(order = 1) |
|
|
|
public R save(@RequestBody @Valid AccidentDTO req) { |
|
|
|
public R save(@RequestBody @Valid AccidentDTO req) { |
|
|
|
AccidentEntity accidentEntity = BeanUtil.copy(req,AccidentEntity.class); |
|
|
|
AccidentEntity accidentEntity = BeanUtil.copy(req, AccidentEntity.class); |
|
|
|
accidentService.save(accidentEntity); |
|
|
|
accidentService.save(accidentEntity); |
|
|
|
return R.data(accidentEntity); |
|
|
|
return R.data(accidentEntity); |
|
|
|
} |
|
|
|
} |
|
|
@ -69,16 +69,14 @@ public class AccidentController extends BladeController { |
|
|
|
public R<AccidentVO> detail(@PathVariable(value = "id") Long id) { |
|
|
|
public R<AccidentVO> detail(@PathVariable(value = "id") Long id) { |
|
|
|
AccidentVO accidentVO = null; |
|
|
|
AccidentVO accidentVO = null; |
|
|
|
readLock.lock(); |
|
|
|
readLock.lock(); |
|
|
|
try{ |
|
|
|
try { |
|
|
|
AccidentEntity accidentEntity = accidentService.getById(id); |
|
|
|
AccidentEntity accidentEntity = accidentService.getById(id); |
|
|
|
if( ObjectUtil.isNotEmpty(accidentEntity)) { |
|
|
|
if (ObjectUtil.isNotEmpty(accidentEntity)) { |
|
|
|
accidentVO = AccidentWrapper.build().entityVO(accidentEntity); |
|
|
|
accidentVO = AccidentWrapper.build().entityVO(accidentEntity); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
catch(Exception e){ |
|
|
|
|
|
|
|
e.printStackTrace(); |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
} finally { |
|
|
|
finally { |
|
|
|
|
|
|
|
readLock.unlock(); |
|
|
|
readLock.unlock(); |
|
|
|
} |
|
|
|
} |
|
|
|
return R.data(accidentVO); |
|
|
|
return R.data(accidentVO); |
|
|
@ -88,16 +86,14 @@ public class AccidentController extends BladeController { |
|
|
|
@ApiOperation("根据ID修改事故") |
|
|
|
@ApiOperation("根据ID修改事故") |
|
|
|
@ApiOperationSupport(order = 3) |
|
|
|
@ApiOperationSupport(order = 3) |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public R updateById (@RequestBody @Valid AccidentDTO req) { |
|
|
|
public R updateById(@RequestBody @Valid AccidentDTO req) { |
|
|
|
writeLock.lock(); |
|
|
|
writeLock.lock(); |
|
|
|
try{ |
|
|
|
try { |
|
|
|
AccidentEntity accidentEntity = BeanUtil.copy(req,AccidentEntity.class); |
|
|
|
AccidentEntity accidentEntity = BeanUtil.copy(req, AccidentEntity.class); |
|
|
|
accidentService.updateById(accidentEntity); |
|
|
|
accidentService.updateById(accidentEntity); |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
catch(Exception e) { |
|
|
|
|
|
|
|
e.printStackTrace(); |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
} finally { |
|
|
|
finally { |
|
|
|
|
|
|
|
writeLock.unlock(); |
|
|
|
writeLock.unlock(); |
|
|
|
} |
|
|
|
} |
|
|
|
return R.success("操作成功"); |
|
|
|
return R.success("操作成功"); |
|
|
@ -116,16 +112,16 @@ public class AccidentController extends BladeController { |
|
|
|
@ApiOperation("分页查询") |
|
|
|
@ApiOperation("分页查询") |
|
|
|
@ApiOperationSupport(order = 5) |
|
|
|
@ApiOperationSupport(order = 5) |
|
|
|
@OperationAnnotation(moduleName = "安全管理", |
|
|
|
@OperationAnnotation(moduleName = "安全管理", |
|
|
|
title = "事故管理",operatorType = OperatorType.MOBILE,businessType = BusinessType.GENCODE, |
|
|
|
title = "事故管理", operatorType = OperatorType.MOBILE, businessType = BusinessType.GENCODE, |
|
|
|
action = "分页条件") |
|
|
|
action = "分页查询事故管理列表") |
|
|
|
public R<IPage> pageList(AccidentDTO req, Query query){ |
|
|
|
public R<IPage> pageList(AccidentDTO req, Query query) { |
|
|
|
AccidentEntity accidentEntity = BeanUtil.copy(req,AccidentEntity.class); |
|
|
|
AccidentEntity accidentEntity = BeanUtil.copy(req, AccidentEntity.class); |
|
|
|
LambdaQueryWrapper<AccidentEntity> queryWrapper = Condition.getQueryWrapper(new AccidentEntity(),accidentEntity); |
|
|
|
LambdaQueryWrapper<AccidentEntity> queryWrapper = Condition.getQueryWrapper(new AccidentEntity(), accidentEntity); |
|
|
|
if(ObjectUtil.isNotEmpty(req.getStatus())){ |
|
|
|
if (ObjectUtil.isNotEmpty(req.getStatus())) { |
|
|
|
queryWrapper.eq(AccidentEntity::getStatus,req.getStatus()); |
|
|
|
queryWrapper.eq(AccidentEntity::getStatus, req.getStatus()); |
|
|
|
} |
|
|
|
} |
|
|
|
IPage page = accidentService.page(Condition.getPage(query),queryWrapper); |
|
|
|
IPage page = accidentService.page(Condition.getPage(query), queryWrapper); |
|
|
|
if(CollectionUtil.isNotEmpty(page.getRecords())){ |
|
|
|
if (CollectionUtil.isNotEmpty(page.getRecords())) { |
|
|
|
page.setRecords(AccidentWrapper.build().listVO(page.getRecords())); |
|
|
|
page.setRecords(AccidentWrapper.build().listVO(page.getRecords())); |
|
|
|
} |
|
|
|
} |
|
|
|
return R.data(page); |
|
|
|
return R.data(page); |
|
|
|