package cn.iocoder.yudao.module.mes.controller.admin.pro.scan; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.module.mes.controller.admin.pro.scan.vo.MesProScanEventCreateReqVO; import cn.iocoder.yudao.module.mes.controller.admin.pro.scan.vo.MesProScanEventRespVO; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.module.mes.controller.admin.pro.scan.vo.MesProScanEventPageReqVO; import java.util.List; import java.util.Map; import cn.iocoder.yudao.module.mes.dal.dataobject.pro.scan.MesProScanEventDO; import cn.iocoder.yudao.module.mes.service.pro.scan.MesProScanEventService; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.annotation.Resource; import jakarta.validation.Valid; import org.springframework.web.bind.annotation.*; import org.springframework.security.access.prepost.PreAuthorize; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; @Tag(name = "管理后台 - MES 扫码入库") @RestController @RequestMapping("/mes/pro/scan-in") public class MesProScanEventController { @Resource private MesProScanEventService service; @PostMapping("/inbound") @PreAuthorize("@ss.hasPermission('mes:pro-scan-in:inbound')") @Operation(summary = "袋码扫码入库") public CommonResult inbound(@Valid @RequestBody MesProScanEventCreateReqVO req) { return success(BeanUtils.toBean(service.createInbound(req), MesProScanEventRespVO.class)); } @GetMapping("/page") @PreAuthorize("@ss.hasPermission('mes:pro-scan-in:query')") @Operation(summary = "扫码事件分页") public CommonResult> page(@Valid MesProScanEventPageReqVO req) { PageResult page = service.getPage(req); return success(new PageResult<>(BeanUtils.toBean(page.getList(), MesProScanEventRespVO.class), page.getTotal())); } @GetMapping("/latest") @PreAuthorize("@ss.hasPermission('mes:pro-scan-in:query')") @Operation(summary = "最新扫码事件") public CommonResult latest(@RequestParam(required = false) String deviceCode) { return success(BeanUtils.toBean(service.getLatest(deviceCode), MesProScanEventRespVO.class)); } @GetMapping("/dashboard") @PreAuthorize("@ss.hasPermission('mes:pro-scan-in:dashboard')") @Operation(summary = "扫码入库看板") public CommonResult> dashboard() { return success(service.getDashboard()); } }