| | |
| | | package com.ruoyi.web.controller.api; |
| | | |
| | | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.basic.PageInfo; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.domain.entity.TDept; |
| | | import com.ruoyi.common.core.domain.model.LoginUser; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import com.ruoyi.system.dto.AddAssetRepairRequestDTO; |
| | | import com.ruoyi.system.dto.AddContractDTO; |
| | | import com.ruoyi.system.model.AssetMain; |
| | | import com.ruoyi.system.model.AssetRepairRequestItem; |
| | | import com.ruoyi.system.query.AssetRepairRequestListQuery; |
| | | import com.ruoyi.system.query.AssetStatisticsListQuery; |
| | | import com.ruoyi.system.service.*; |
| | | import com.ruoyi.system.vo.AssetRepairRequestVO; |
| | | import com.ruoyi.system.vo.AssetStatisticsVO; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/asset-repair-request") |
| | | public class AssetRepairRequestController { |
| | | @Api(tags = {"资产报修"}) |
| | | |
| | | public class AssetRepairRequestController { |
| | | @Resource |
| | | private AssetRepairRecordService assetRepairRecordService; |
| | | @Resource |
| | | private AssetRepairRequestService assetRepairRequestService; |
| | | @Resource |
| | | private AssetRepairRequestItemService assetRepairRequestItemService; |
| | | @Autowired |
| | | private TokenService tokenService; |
| | | @Autowired |
| | | private TDeptService deptService; |
| | | @Resource |
| | | private AssetMainService assetMainService; |
| | | |
| | | @ApiOperation("资产报修分页列表") |
| | | @PostMapping("/pageList") |
| | | public R<PageInfo<AssetRepairRequestVO>> pageList(@RequestBody AssetRepairRequestListQuery query) { |
| | | String deptId = tokenService.getLoginUser().getDeptId(); |
| | | List<Integer> deptIds = deptService.getAllSubDeptIds(deptId); |
| | | if (deptIds.isEmpty()) { |
| | | return R.ok(new PageInfo<>()); |
| | | } else { |
| | | query.setDeptIds(deptIds); |
| | | } |
| | | List<Integer> assetMainIds = assetMainService.lambdaQuery().in(AssetMain::getOwnershipDeptId, deptIds).list() |
| | | .stream().map(AssetMain::getId).collect(Collectors.toList()); |
| | | if (assetMainIds.isEmpty()){ |
| | | return R.ok(new PageInfo<>()); |
| | | } |
| | | query.setAssetMainIds(assetMainIds); |
| | | return R.ok(assetRepairRecordService.pageList(query)); |
| | | } |
| | | @Log(title = "资产报修-新增", businessType = BusinessType.INSERT) |
| | | @ApiOperation(value = "资产报修新增") |
| | | @PostMapping(value = "/add") |
| | | public R add(@RequestBody AddAssetRepairRequestDTO dto) { |
| | | assetRepairRequestService.save(dto); |
| | | assetRepairRequestItemService.saveBatch(dto.getList()); |
| | | return R.ok(); |
| | | |
| | | } |
| | | @Log(title = "资产报修-编辑", businessType = BusinessType.INSERT) |
| | | @ApiOperation(value = "资产报修编辑") |
| | | @PostMapping(value = "/update") |
| | | public R update(@RequestBody AddAssetRepairRequestDTO dto) { |
| | | assetRepairRequestService.updateById(dto); |
| | | assetRepairRequestItemService.remove(new LambdaQueryWrapper<AssetRepairRequestItem>() |
| | | .eq(AssetRepairRequestItem::getRepairRequestId, dto.getId())); |
| | | assetRepairRequestItemService.saveBatch(dto.getList()); |
| | | return R.ok(); |
| | | } |
| | | @Log(title = "资产报修-删除", businessType = BusinessType.DELETE) |
| | | @ApiOperation(value = "资产报修-删除") |
| | | @DeleteMapping(value = "/delete") |
| | | public R delete(@RequestParam String ids) { |
| | | assetRepairRequestItemService.remove(new LambdaQueryWrapper<AssetRepairRequestItem>() |
| | | .in(AssetRepairRequestItem::getRepairRequestId, Arrays.asList(ids.split(",")))); |
| | | assetRepairRequestService.removeBatchByIds(Arrays.asList(ids.split(","))); |
| | | return R.ok(); |
| | | } |
| | | } |
| | | |