| | |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Log; |
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType; |
| | | import com.ruoyi.framework.web.controller.BaseController; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import com.ruoyi.framework.web.domain.R; |
| | | import com.ruoyi.measuringinstrumentledger.dto.MeasuringInstrumentLedgerDto; |
| | | import com.ruoyi.measuringinstrumentledger.mapper.MeasuringInstrumentLedgerRecordMapper; |
| | | import com.ruoyi.measuringinstrumentledger.pojo.MeasuringInstrumentLedger; |
| | |
| | | @GetMapping("/listPage") |
| | | @Operation(summary = "计量器具台账-分页查询") |
| | | @Log(title = "计量器具台账-分页查询", businessType = BusinessType.OTHER) |
| | | public AjaxResult listPage(Page page, MeasuringInstrumentLedger measuringInstrumentLedger) { |
| | | public R<?> listPage(Page page, MeasuringInstrumentLedger measuringInstrumentLedger) { |
| | | IPage<MeasuringInstrumentLedger> listPage = measuringInstrumentLedgerService.listPage(page, measuringInstrumentLedger); |
| | | return AjaxResult.success(listPage); |
| | | return R.ok(listPage); |
| | | } |
| | | |
| | | |
| | |
| | | @Operation(summary = "计量器具台账-新增") |
| | | @Log(title = "计量器具台账-新增", businessType = BusinessType.INSERT) |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public AjaxResult add(@RequestBody MeasuringInstrumentLedger measuringInstrumentLedger) throws IOException { |
| | | public R<?> add(@RequestBody MeasuringInstrumentLedger measuringInstrumentLedger) throws IOException { |
| | | boolean save = measuringInstrumentLedgerService.add(measuringInstrumentLedger); |
| | | if (save) { |
| | | return AjaxResult.success(); |
| | | return R.ok(); |
| | | } |
| | | return AjaxResult.error(); |
| | | return R.fail(); |
| | | } |
| | | |
| | | @PostMapping("/update") |
| | | @Operation(summary = "计量器具台账-修改") |
| | | @Log(title = "计量器具台账-修改", businessType = BusinessType.UPDATE) |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public AjaxResult update(@RequestBody MeasuringInstrumentLedger measuringInstrumentLedger) { |
| | | public R<?> update(@RequestBody MeasuringInstrumentLedger measuringInstrumentLedger) { |
| | | SysUser sysUser = sysUserMapper.selectUserById(measuringInstrumentLedger.getUserId()); |
| | | if (sysUser == null) { |
| | | return AjaxResult.error("用户不存在"); |
| | | return R.fail("用户不存在"); |
| | | } |
| | | measuringInstrumentLedger.setUserName(sysUser.getUserName()); |
| | | boolean update = measuringInstrumentLedgerService.updateById(measuringInstrumentLedger); |
| | | if (update) { |
| | | return AjaxResult.success(); |
| | | return R.ok(); |
| | | } |
| | | return AjaxResult.error(); |
| | | return R.fail(); |
| | | } |
| | | |
| | | @DeleteMapping("/delete") |
| | | @Operation(summary = "计量器具台账-删除") |
| | | @Log(title = "计量器具台账-删除", businessType = BusinessType.DELETE) |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public AjaxResult delete(@RequestBody List<Long> ids) { |
| | | if(CollectionUtils.isEmpty(ids)) return AjaxResult.error("请选择至少一条数据"); |
| | | public R<?> delete(@RequestBody List<Long> ids) { |
| | | if(CollectionUtils.isEmpty(ids)) return R.fail("请选择至少一条数据"); |
| | | for (Long id : ids) { |
| | | LambdaQueryWrapper<MeasuringInstrumentLedgerRecord> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(MeasuringInstrumentLedgerRecord::getMeasuringInstrumentLedgerId,id); |
| | | List<MeasuringInstrumentLedgerRecord> measuringInstrumentLedgerRecords = measuringInstrumentLedgerRecordMapper.selectList(queryWrapper); |
| | | if(!CollectionUtils.isEmpty(measuringInstrumentLedgerRecords)){ |
| | | return AjaxResult.error("请先删除选中计量器具台账下的所有检定记录"); |
| | | return R.fail("请先删除选中计量器具台账下的所有检定记录"); |
| | | } |
| | | } |
| | | boolean delete = measuringInstrumentLedgerService.removeBatchByIds(ids); |
| | | if (delete) { |
| | | return AjaxResult.success(); |
| | | return R.ok(); |
| | | } |
| | | return AjaxResult.error(); |
| | | return R.fail(); |
| | | } |
| | | |
| | | @PostMapping("/verifying") |
| | | @Operation(summary = "计量器具台账-检定") |
| | | @Log(title = "计量器具台账-检定", businessType = BusinessType.UPDATE) |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public AjaxResult verifying(@RequestBody MeasuringInstrumentLedgerDto measuringInstrumentLedger) throws IOException { |
| | | public R<?> verifying(@RequestBody MeasuringInstrumentLedgerDto measuringInstrumentLedger) throws IOException { |
| | | boolean update = measuringInstrumentLedgerService.verifying(measuringInstrumentLedger); |
| | | return update ? AjaxResult.success("检定成功") : AjaxResult.error("检定失败"); |
| | | return update ? R.ok(null, "检定成功") : R.fail("检定失败"); |
| | | } |
| | | |
| | | /** |