| | |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Log; |
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType; |
| | | import com.ruoyi.framework.web.domain.R; |
| | | import com.ruoyi.quality.mapper.QualityUnqualifiedOrderMapper; |
| | | import com.ruoyi.quality.pojo.QualityUnqualifiedOrder; |
| | | import com.ruoyi.quality.service.IQualityUnqualifiedOrderService; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import jakarta.annotation.Resource; |
| | |
| | | @Resource |
| | | private IQualityUnqualifiedOrderService orderService; |
| | | @Resource |
| | | private QualityUnqualifiedOrderMapper orderMapper; |
| | | @Resource |
| | | private FileUtil fileUtil; |
| | | |
| | | @PostMapping("/save") |
| | |
| | | @Log(title = "新增不合格品处理单", businessType = BusinessType.INSERT) |
| | | public R<?> save(@RequestBody QualityUnqualifiedOrder order) { |
| | | String orderNo = OrderUtils.countTodayByCreateTime( |
| | | orderService.getBaseMapper(), "BHG", "order_no", |
| | | orderMapper, "BHG", "order_no", |
| | | order.getCreateTime() != null ? order.getCreateTime() : LocalDateTime.now()); |
| | | order.setOrderNo(orderNo); |
| | | order.setStatus(0); |
| | | orderService.save(order); |
| | | fileUtil.saveStorageAttachment(ApplicationTypeEnum.FILE, RecordTypeEnum.QUALITY_UNQUALIFIED_ORDER, order.getId(), order.getStorageBlobDTOs()); |
| | | return R.ok(true); |
| | | if (order.getStatus() == null) { |
| | | order.setStatus(order.getDisposalMethod() != null ? 3 : 0); |
| | | } |
| | | boolean result = orderService.save(order); |
| | | if (result) { |
| | | fileUtil.saveStorageAttachment(ApplicationTypeEnum.FILE, RecordTypeEnum.QUALITY_UNQUALIFIED_ORDER, order.getId(), order.getStorageBlobDTOs()); |
| | | } |
| | | return R.ok(result); |
| | | } |
| | | |
| | | @PutMapping("/update") |
| | | @Operation(summary = "修改不合格品处理单") |
| | | @Log(title = "修改不合格品处理单", businessType = BusinessType.UPDATE) |
| | | public R<?> update(@RequestBody QualityUnqualifiedOrder order) { |
| | | orderService.updateById(order); |
| | | fileUtil.saveStorageAttachment(ApplicationTypeEnum.FILE, RecordTypeEnum.QUALITY_UNQUALIFIED_ORDER, order.getId(), order.getStorageBlobDTOs()); |
| | | return R.ok(true); |
| | | boolean result = orderService.updateWithRework(order); |
| | | if (result) { |
| | | fileUtil.saveStorageAttachment(ApplicationTypeEnum.FILE, RecordTypeEnum.QUALITY_UNQUALIFIED_ORDER, order.getId(), order.getStorageBlobDTOs()); |
| | | } |
| | | return R.ok(result); |
| | | } |
| | | |
| | | @DeleteMapping("/delete") |
| | | @Operation(summary = "删除不合格品处理单") |
| | | @Log(title = "删除不合格品处理单", businessType = BusinessType.DELETE) |
| | | public R<?> delete(@RequestBody List<Long> ids) { |
| | | return R.ok(orderService.removeBatchByIds(ids)); |
| | | return R.ok(orderMapper.deleteByIds(ids) > 0); |
| | | } |
| | | |
| | | @GetMapping("/listPage") |
| | |
| | | public R<?> detail(@PathVariable Long id) { |
| | | return R.ok(orderService.getDetail(id)); |
| | | } |
| | | |
| | | @PostMapping("/deal") |
| | | @Operation(summary = "不合格品处理") |
| | | @Log(title = "不合格品处理", businessType = BusinessType.OTHER) |
| | | public R<?> deal(@RequestBody QualityUnqualifiedOrder order) { |
| | | return R.ok(orderService.deal(order)); |
| | | } |
| | | |
| | | @GetMapping("/export/{id}") |
| | | @Operation(summary = "导出不合格品处理单") |
| | | @Log(title = "导出不合格品处理单", businessType = BusinessType.EXPORT) |
| | | public void export(@PathVariable Long id, HttpServletResponse response) { |
| | | orderService.export(id, response); |
| | | } |
| | | } |