| | |
| | | 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 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.*; |
| | | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.time.LocalDate; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | * 获取维修物品二级结构 |
| | | */ |
| | | @ApiOperation(value = "获取维修物品二级结构") |
| | | @PostMapping(value = "/getItemList") |
| | | public R<List<TItemTypeVO>> getItemList() { |
| | | List<TItemTypeVO> itemTypes = itemTypeService.getItemList(); |
| | | @GetMapping(value = "/getItemList") |
| | | public R<List<TItemTypeVO>> getItemList(@RequestParam(required = false) String itemName) { |
| | | List<TItemTypeVO> itemTypes = itemTypeService.getItemList(itemName); |
| | | List<TItem> items = itemService.list(); |
| | | itemTypes.forEach(itemType -> { |
| | | itemType.setItemList(items.stream().filter(item -> itemType.getId().equals(item.getTypeId())).collect(Collectors.toList())); |
| | | itemType.setItemList(items.stream().filter(item -> itemType.getId().equals(item.getTypeId()) && item.getItemName().contains(itemName)).collect(Collectors.toList())); |
| | | }); |
| | | return R.ok(itemTypes); |
| | | } |
| | |
| | | @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(); |
| | | } |