package com.newfiber.modules.inspection.controller; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.github.pagehelper.PageHelper; import com.newfiber.common.utils.Constant; import com.newfiber.common.utils.R; import com.newfiber.modules.inspection.entity.InspectionUserItem; import com.newfiber.modules.inspection.enums.EBoolean; import com.newfiber.modules.inspection.request.InspectionStatisRequest; import com.newfiber.modules.inspection.request.InspectionUserItemAbnormalListRequest; import com.newfiber.modules.inspection.request.InspectionUserItemCheckReq; import com.newfiber.modules.inspection.request.InspectionUserItemSaveReq; import com.newfiber.modules.inspection.service.InspectionUserItemService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperationSupport; import java.util.Arrays; import java.util.Map; import javax.annotation.Resource; import javax.validation.Valid; import org.springframework.beans.BeanUtils; import org.springframework.web.bind.annotation.PathVariable; 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; /** * 用户巡检检测项Controller * * @author : xiongk * @since : 2020-11-06 10:00 */ @RestController @Api(value = "用户巡检检测项管理", tags = "用户巡检检测项管理") @RequestMapping("/inspection_user_item") public class InspectionUserItemController{ @Resource private InspectionUserItemService inspectionUserItemService; @ApiOperation(value = "新增用户巡检检测项", hidden = true) @ApiOperationSupport(order = 10) @PostMapping(value = "/save") public R save(@RequestBody @Valid InspectionUserItemSaveReq request) { InspectionUserItem inspectionUserItem = new InspectionUserItem(); BeanUtils.copyProperties(request, inspectionUserItem); inspectionUserItemService.save(inspectionUserItem); return R.ok(); } @ApiOperation(value = "删除用户巡检检测项", hidden = true) @ApiOperationSupport(order = 20) @PostMapping("/delete") public R delete(@RequestBody Integer[] ids) { inspectionUserItemService.removeByIds(Arrays.asList(ids)); return R.ok(); } @ApiOperation(value = "用户巡检检测项打卡", hidden = true) @ApiOperationSupport(order = 30) @PostMapping(value = "/check") public R check(@RequestBody @Valid InspectionUserItemCheckReq request) { inspectionUserItemService.check(request); return R.ok(); } @ApiOperation(value = "详细查询用户巡检检测项") @ApiOperationSupport(order = 40) @PostMapping("/detail/{id}") public R detail(@PathVariable("id") @Valid Integer id) { return R.ok().put("data", inspectionUserItemService.getById(id)); } @ApiOperation(value = "分页条件查询用户巡检检测项") @ApiOperationSupport(order = 50) @PostMapping(value = "/page") public R page(@RequestBody Map<String, Object> params) { int page = Integer.parseInt(params.get(Constant.PAGE).toString()); int limit = Integer.parseInt(params.get(Constant.LIMIT).toString()); PageHelper.startPage(page, limit); params.remove(Constant.PAGE); params.remove(Constant.LIMIT); return R.ok().put("page", inspectionUserItemService.listByMap(params)); } @ApiOperation(value = "列表条件查询用户巡检检测项") @ApiOperationSupport(order = 60) @PostMapping(value = "/list") public R list(@RequestBody Map<String, Object> params) { return R.ok().put("list", inspectionUserItemService.listByMap(params)); } @ApiOperation(value = "列表条件查询异常用户巡检检测项") @ApiOperationSupport(order = 60) @PostMapping(value = "/list_abnormal") public R list(@RequestBody InspectionUserItemAbnormalListRequest request) { QueryWrapper<InspectionUserItem> queryWrapper = new QueryWrapper<InspectionUserItem>(). eq("equ_no", request.getEquNo()). eq("item_id", request.getItemId()). eq("result", EBoolean.YES.getKey()). eq("date_format(create_datetime, '%Y-%m')", request.getCreateDate()); return R.ok().put("list", inspectionUserItemService.list(queryWrapper)); } @ApiOperation(value = "巡检结果统计") @ApiOperationSupport(order = 60) @PostMapping(value = "/statis") public R statis(@RequestBody InspectionStatisRequest request) { return R.ok().put("list", inspectionUserItemService.inspectionStatis(request)); } }