src/main/java/com/ruoyi/production/controller/ProductInspectionRecordController.java
@@ -3,17 +3,21 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.production.dto.ProductInspectionRecordDto;
import com.ruoyi.production.pojo.ProductInspectionRecord;
import com.ruoyi.production.service.ProductInspectionRecordService;
import com.ruoyi.project.system.domain.SysUser;
import com.ruoyi.project.system.service.ISysUserService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Objects;
/**
 * <p>
@@ -28,13 +32,34 @@
public class ProductInspectionRecordController {
    @Autowired
    private ProductInspectionRecordService productInspectionRecordService;
    @Autowired
    private ISysUserService sysUserService;
    @ApiOperation("巡检记录 分页查询")
    @GetMapping("listPage")
    @Log(title = "巡检记录 分页查询", businessType = BusinessType.OTHER)
    public AjaxResult page(ProductInspectionRecordDto productInspectionRecord, Page<ProductInspectionRecord> page) {
        LambdaQueryWrapper<ProductInspectionRecord> ew = Wrappers.<ProductInspectionRecord>lambdaQuery();
        return AjaxResult.success(productInspectionRecordService.page(page, ew));
        ew.eq(StringUtils.isNotEmpty(productInspectionRecord.getProcess()), ProductInspectionRecord::getProcess, productInspectionRecord.getProcess())
                .eq(StringUtils.isNotEmpty(productInspectionRecord.getProcessId()), ProductInspectionRecord::getProcessId, productInspectionRecord.getProcessId())
                .between(Objects.nonNull(productInspectionRecord.getStartTime()) && Objects.nonNull(productInspectionRecord.getEndTime()),
                        ProductInspectionRecord::getInspectionTime, productInspectionRecord.getStartTime(),
                        productInspectionRecord.getEndTime());
        // 查询分页数据
        Page<ProductInspectionRecord> resultPage = productInspectionRecordService.page(page, ew);
        List<ProductInspectionRecord> records = resultPage.getRecords();
        for (ProductInspectionRecord record : records) {
            if (record.getCreateUser() != null) {
                Long userId = record.getCreateUser().longValue();
                SysUser user = sysUserService.selectUserById(userId);
                if (user != null) {
                    record.setCreateUserName(user.getNickName());
                }
            }
        }
        return AjaxResult.success(resultPage);
    }
    @ApiOperation("巡检记录 新增")
@@ -61,4 +86,12 @@
        productInspectionRecordService.removeBatchByIds(ids);
        return AjaxResult.success();
    }
    @ApiOperation("巡检记录 通知")
    @PostMapping("/notify")
    @Log(title = "巡检记录 通知", businessType = BusinessType.OTHER)
    public AjaxResult notify(@RequestBody List<Long> ids) {
        productInspectionRecordService.notify(ids);
        return AjaxResult.success("发送通知成功");
    }
}