| | |
| | | package com.ruoyi.web.controller.api; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import com.ruoyi.system.dto.TFaultRepairMessageDTO; |
| | | import com.ruoyi.system.model.*; |
| | | import com.ruoyi.system.service.*; |
| | | import com.ruoyi.system.vo.TFaultAreaDicVO; |
| | | import com.ruoyi.system.vo.TItemTypeVO; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.time.LocalDate; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | * @author xiaochen |
| | | * @since 2025-01-17 |
| | | */ |
| | | @Api(tags = "报修管理") |
| | | @RestController |
| | | @RequestMapping("/t-fault-repair-message") |
| | | public class TFaultRepairMessageController { |
| | | |
| | | private final TFaultRepairMessageService tFaultRepairMessageService; |
| | | private final TItemService itemService; |
| | | private final TItemTypeService itemTypeService; |
| | | private final TFaultAreaDicService faultAreaDicService; |
| | | private final TFaultDescribeDicService faultDescribeDicService; |
| | | private final TokenService tokenService; |
| | | private final TContractService contractService; |
| | | private final THouseService houseService; |
| | | |
| | | @Autowired |
| | | public TFaultRepairMessageController(TFaultRepairMessageService tFaultRepairMessageService, TItemService itemService, TItemTypeService itemTypeService, TFaultAreaDicService faultAreaDicService, TFaultDescribeDicService faultDescribeDicService, TokenService tokenService, TContractService contractService, THouseService houseService) { |
| | | this.tFaultRepairMessageService = tFaultRepairMessageService; |
| | | this.itemService = itemService; |
| | | this.itemTypeService = itemTypeService; |
| | | this.faultAreaDicService = faultAreaDicService; |
| | | this.faultDescribeDicService = faultDescribeDicService; |
| | | this.tokenService = tokenService; |
| | | this.contractService = contractService; |
| | | this.houseService = houseService; |
| | | } |
| | | |
| | | /** |
| | | * 获取维修物品二级结构 |
| | | */ |
| | | @ApiOperation(value = "获取维修物品二级结构") |
| | | @PostMapping(value = "/getItemList") |
| | | public R<List<TItemTypeVO>> getItemList() { |
| | | List<TItemTypeVO> itemTypes = itemTypeService.getItemList(); |
| | | List<TItem> items = itemService.list(); |
| | | itemTypes.forEach(itemType -> { |
| | | itemType.setItemList(items.stream().filter(item -> itemType.getId().equals(item.getTypeId())).collect(Collectors.toList())); |
| | | }); |
| | | return R.ok(itemTypes); |
| | | } |
| | | |
| | | /** |
| | | * 获取故障区域列表 |
| | | */ |
| | | @ApiOperation(value = "获取故障区域二级结构") |
| | | @PostMapping(value = "/getAreaDicList") |
| | | public R<List<TFaultAreaDicVO>> getAreaDicList() { |
| | | List<TFaultAreaDicVO> faultAreaDicVOS = faultAreaDicService.getAreaDicList(); |
| | | List<TFaultDescribeDic> faultDescribeDicList = faultDescribeDicService.list(); |
| | | faultAreaDicVOS.forEach(areaDicVO -> { |
| | | areaDicVO.setFaultDescribeDicList(faultDescribeDicList.stream().filter(item -> areaDicVO.getId().equals(item.getFaultId())).collect(Collectors.toList())); |
| | | }); |
| | | return R.ok(faultAreaDicVOS); |
| | | } |
| | | |
| | | /** |
| | | * 通过当前租户查询合同房源信息 |
| | | */ |
| | | @ApiOperation(value = "通过当前租户查询合同房源信息") |
| | | @PostMapping(value = "/getConcatByTenantId") |
| | | public R<List<TContract>> getConcatByTenantId() { |
| | | |
| | | String tenantId = tokenService.getLoginUserApplet().getUserId(); |
| | | // 查询合同信息 |
| | | List<TContract> list = contractService.list(Wrappers.lambdaQuery(TContract.class) |
| | | .eq(TContract::getTenantId, tenantId) |
| | | .eq(TContract::getStatus, 4)); |
| | | if(CollectionUtils.isEmpty(list)){ |
| | | return R.ok(list); |
| | | } |
| | | List<String> houseIds = list.stream().map(TContract::getHouseId).collect(Collectors.toList()); |
| | | List<THouse> houseList = houseService.list(Wrappers.lambdaQuery(THouse.class) |
| | | .in(THouse::getId, houseIds)); |
| | | list.forEach(item -> { |
| | | item.setHouseName(houseList.stream().filter(house -> house.getId().equals(item.getHouseId())).findFirst().orElse(new THouse()).getHouseName()); |
| | | item.setHouseAddress(houseList.stream().filter(house -> house.getId().equals(item.getHouseId())).findFirst().orElse(new THouse()).getHouseAddress()); |
| | | }); |
| | | return R.ok(list); |
| | | } |
| | | |
| | | /** |
| | | * 添加报修信息 |
| | | */ |
| | | @ApiOperation(value = "添加报修信息") |
| | | @PostMapping(value = "/addFault") |
| | | public R<String> addFault(@RequestBody TFaultRepairMessageDTO dto) { |
| | | dto.setTenantId(tokenService.getLoginUserApplet().getUserId()); |
| | | LocalDate now = LocalDate.now(); |
| | | String replace = (now + "").replace("-", ""); |
| | | int size = tFaultRepairMessageService.list(new LambdaQueryWrapper<TFaultRepairMessage>() |
| | | .likeRight(TFaultRepairMessage::getCreateTime, LocalDate.now())).size(); |
| | | dto.setCode(replace.substring(2)+String.format("%03d", size+1)); |
| | | tFaultRepairMessageService.save(dto); |
| | | return R.ok(); |
| | | } |
| | | |
| | | } |
| | | |