Merge remote-tracking branch '惠信/qms/develop' into qms/develop
This commit is contained in:
commit
b05f5b24d6
|
|
@ -0,0 +1,137 @@
|
|||
package com.nflg.qms.admin.controller;
|
||||
|
||||
import com.nflg.qms.admin.service.QmsPdiDetectionRulesControllerService;
|
||||
import com.nflg.wms.common.pojo.ApiResult;
|
||||
import com.nflg.wms.common.pojo.PageData;
|
||||
import com.nflg.wms.common.pojo.dto.QmsPdiMachineImportDTO;
|
||||
import com.nflg.wms.common.pojo.qo.QmsPdiDetectionRulesAddQO;
|
||||
import com.nflg.wms.common.pojo.qo.QmsPdiDetectionRulesSearchQO;
|
||||
import com.nflg.wms.common.pojo.qo.QmsPdiDetectionRulesUpdateQO;
|
||||
import com.nflg.wms.common.pojo.vo.QmsPdiDetectionRulesVO;
|
||||
import com.nflg.wms.common.util.EecExcelUtil;
|
||||
import com.nflg.wms.starter.BaseController;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* PDI检测规则管理
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/pdiDetectionRules")
|
||||
public class QmsPdiDetectionRulesController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private QmsPdiDetectionRulesControllerService pdiDetectionRulesControllerService;
|
||||
|
||||
/**
|
||||
* 新增PDI检测规则
|
||||
* 参数:机型编号、质检负责人id、质检周期、质检类型、销售订单号(全部必传)
|
||||
* 自动生成规则编号和版本号,状态/发布状态/维护状态默认均为 false
|
||||
*/
|
||||
@Transactional
|
||||
@PostMapping("add")
|
||||
public ApiResult<Void> add(@Valid @RequestBody QmsPdiDetectionRulesAddQO request) {
|
||||
pdiDetectionRulesControllerService.add(request);
|
||||
return ApiResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑PDI检测规则
|
||||
* 参数:ID(必传)、其余字段可选传入
|
||||
* 修改后自动重新计算版本号
|
||||
*/
|
||||
@Transactional
|
||||
@PostMapping("update")
|
||||
public ApiResult<Void> update(@Valid @RequestBody QmsPdiDetectionRulesUpdateQO request) {
|
||||
pdiDetectionRulesControllerService.update(request);
|
||||
return ApiResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除PDI检测规则
|
||||
* 已发布不可删除;未发布且已启用也不可删除
|
||||
*
|
||||
* @param id 规则ID
|
||||
*/
|
||||
@Transactional
|
||||
@PostMapping("delete")
|
||||
public ApiResult<Void> delete(@NotNull(message = "ID不能为空") Long id) {
|
||||
pdiDetectionRulesControllerService.delete(id);
|
||||
return ApiResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量发布PDI检测规则
|
||||
* 禁用或未维护的规则不允许发布
|
||||
*
|
||||
* @param ids 规则ID列表(必传)
|
||||
*/
|
||||
@Transactional
|
||||
@PostMapping("publish")
|
||||
public ApiResult<Void> publish(@RequestBody List<Long> ids) {
|
||||
pdiDetectionRulesControllerService.publish(ids);
|
||||
return ApiResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询PDI检测规则
|
||||
* 支持机型编号、销售订单号精确查询,发布日期区间过滤(均可选)
|
||||
*/
|
||||
@PostMapping("search")
|
||||
public ApiResult<PageData<QmsPdiDetectionRulesVO>> search(@RequestBody QmsPdiDetectionRulesSearchQO request) {
|
||||
return ApiResult.success(pdiDetectionRulesControllerService.search(request));
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出机型
|
||||
* ids 为空则全量导出,否则按ID导出
|
||||
*
|
||||
* @param ids 规则ID列表(可选)
|
||||
*/
|
||||
@PostMapping("exportMachine")
|
||||
public void exportMachine(HttpServletResponse response,
|
||||
@RequestBody(required = false) List<Long> ids) throws IOException {
|
||||
pdiDetectionRulesControllerService.exportMachine(response, ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载机型导入模板
|
||||
*/
|
||||
@GetMapping("machineTemplate")
|
||||
public void machineTemplate(HttpServletResponse response) throws IOException {
|
||||
EecExcelUtil.export("PDI机型导入模板",
|
||||
Arrays.asList("*机型编号", "*销售订单号", "*检测类型(0=新机检测,1=库存检测)", "*检测周期", "*质检员ID"),
|
||||
List.of(), response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入机型(批量新增PDI检测规则)
|
||||
*/
|
||||
@Transactional
|
||||
@PostMapping("importMachine")
|
||||
public ApiResult<Void> importMachine(@RequestParam("file") MultipartFile file) throws IOException {
|
||||
pdiDetectionRulesControllerService.importMachine(file);
|
||||
return ApiResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出PDI检测规则
|
||||
* ids 为空则全量导出,否则按ID导出
|
||||
*
|
||||
* @param ids 规则ID列表(可选)
|
||||
*/
|
||||
@PostMapping("export")
|
||||
public void export(HttpServletResponse response,
|
||||
@RequestBody(required = false) List<Long> ids) throws IOException {
|
||||
pdiDetectionRulesControllerService.export(response, ids);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,99 @@
|
|||
package com.nflg.qms.admin.controller;
|
||||
|
||||
import com.nflg.qms.admin.service.QmsPdiStatusItemControllerService;
|
||||
import com.nflg.wms.common.pojo.ApiResult;
|
||||
import com.nflg.wms.common.pojo.qo.QmsPdiStatusItemAddQO;
|
||||
import com.nflg.wms.common.pojo.qo.QmsPdiStatusItemUpdateQO;
|
||||
import com.nflg.wms.common.pojo.vo.QmsPdiStatusItemGroupVO;
|
||||
import com.nflg.wms.common.util.EecExcelUtil;
|
||||
import com.nflg.wms.starter.BaseController;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* PDI动静态检测项管理
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/pdiStatusItem")
|
||||
public class QmsPdiStatusItemController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private QmsPdiStatusItemControllerService statusItemControllerService;
|
||||
|
||||
/**
|
||||
* 新增检测项
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
public ApiResult<?> add(@Valid @RequestBody QmsPdiStatusItemAddQO request) {
|
||||
statusItemControllerService.add(request);
|
||||
return ApiResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改检测项
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
public ApiResult<?> update(@Valid @RequestBody QmsPdiStatusItemUpdateQO request) {
|
||||
statusItemControllerService.update(request);
|
||||
return ApiResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除检测项
|
||||
*/
|
||||
@PostMapping("/delete")
|
||||
public ApiResult<?> delete(@NotNull(message = "ID不能为空") @RequestParam Long id) {
|
||||
statusItemControllerService.delete(id);
|
||||
return ApiResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出检测项
|
||||
* ids可选,detectionRulesId和status必传
|
||||
*/
|
||||
@GetMapping("/export")
|
||||
public void export(HttpServletResponse response,
|
||||
@RequestParam(required = false) List<Long> ids,
|
||||
@NotNull(message = "PDI检测规则ID不能为空") @RequestParam Long detectionRulesId,
|
||||
@NotNull(message = "状态不能为空") @RequestParam Integer status) throws IOException {
|
||||
statusItemControllerService.export(response, ids, detectionRulesId, status);
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载导入模板
|
||||
*/
|
||||
@GetMapping("/importTemplate")
|
||||
public void importTemplate(HttpServletResponse response) throws IOException {
|
||||
EecExcelUtil.export("PDI检测项导入模板",
|
||||
Arrays.asList("*部件描述", "*检查核实内容", "检测示例图"),
|
||||
List.of(), response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入检测项
|
||||
*/
|
||||
@PostMapping("/import")
|
||||
public ApiResult<?> importData(@RequestParam("file") MultipartFile file,
|
||||
@NotNull(message = "PDI检测规则ID不能为空") @RequestParam Long detectionRulesId,
|
||||
@NotNull(message = "状态不能为空") @RequestParam Integer status) throws IOException {
|
||||
statusItemControllerService.importFromExcel(file, detectionRulesId, status);
|
||||
return ApiResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询(按状态分组返回)
|
||||
*/
|
||||
@GetMapping("/search")
|
||||
public ApiResult<QmsPdiStatusItemGroupVO> search(
|
||||
@NotNull(message = "PDI检测规则ID不能为空") @RequestParam Long detectionRulesId) {
|
||||
return ApiResult.success(statusItemControllerService.search(detectionRulesId));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,307 @@
|
|||
package com.nflg.qms.admin.service;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.nflg.wms.common.constant.STATE;
|
||||
import com.nflg.wms.common.exception.NflgException;
|
||||
import com.nflg.wms.common.pojo.PageData;
|
||||
import com.nflg.wms.common.pojo.dto.QmsPdiDetectionRulesExportDTO;
|
||||
import com.nflg.wms.common.pojo.dto.QmsPdiMachineExportDTO;
|
||||
import com.nflg.wms.common.pojo.dto.QmsPdiMachineImportDTO;
|
||||
import com.nflg.wms.common.pojo.qo.QmsPdiDetectionRulesAddQO;
|
||||
import com.nflg.wms.common.pojo.qo.QmsPdiDetectionRulesSearchQO;
|
||||
import com.nflg.wms.common.pojo.qo.QmsPdiDetectionRulesUpdateQO;
|
||||
import com.nflg.wms.common.pojo.vo.QmsPdiDetectionRulesVO;
|
||||
import com.nflg.wms.common.util.EecExcelUtil;
|
||||
import com.nflg.wms.common.util.UserUtil;
|
||||
import com.nflg.wms.repository.entity.QmsPdiDetectionRules;
|
||||
import com.nflg.wms.repository.mapper.QmsPdiDetectionRulesMapper;
|
||||
import com.nflg.wms.repository.service.IQmsPdiDetectionRulesService;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* PDI检测规则 业务逻辑
|
||||
*/
|
||||
@Component
|
||||
public class QmsPdiDetectionRulesControllerService {
|
||||
|
||||
@Resource
|
||||
private IQmsPdiDetectionRulesService pdiDetectionRulesService;
|
||||
|
||||
@Resource
|
||||
private QmsPdiDetectionRulesMapper pdiDetectionRulesMapper;
|
||||
|
||||
@Resource
|
||||
private BasdeSerialNumberControllerService basdeSerialNumberControllerService;
|
||||
|
||||
// ========================= 工具方法 =========================
|
||||
|
||||
/**
|
||||
* 计算下一个版本号
|
||||
* 查询相同 machineNo + inspectionType + orderNo 的最大版本号,取最大值(不+1)
|
||||
* 若无匹配记录则返回 v1
|
||||
*/
|
||||
private String calcVersion(String machineNo, Integer inspectionType, String orderNo, Long excludeId) {
|
||||
var query = pdiDetectionRulesService.lambdaQuery()
|
||||
.eq(QmsPdiDetectionRules::getMachineNo, machineNo)
|
||||
.eq(QmsPdiDetectionRules::getInspectionType, inspectionType)
|
||||
.eq(QmsPdiDetectionRules::getOrderNo, orderNo);
|
||||
if (excludeId != null) {
|
||||
query = query.ne(QmsPdiDetectionRules::getId, excludeId);
|
||||
}
|
||||
List<QmsPdiDetectionRules> existList = query.list();
|
||||
if (existList.isEmpty()) {
|
||||
return "v1";
|
||||
}
|
||||
Pattern pattern = Pattern.compile("^v(\\d+)$");
|
||||
int maxVersion = existList.stream()
|
||||
.map(QmsPdiDetectionRules::getInspectionVersion)
|
||||
.filter(v -> v != null)
|
||||
.map(v -> {
|
||||
Matcher m = pattern.matcher(v);
|
||||
return m.matches() ? Integer.parseInt(m.group(1)) : 0;
|
||||
})
|
||||
.max(Comparator.naturalOrder())
|
||||
.orElse(0);
|
||||
return "v" + maxVersion;
|
||||
}
|
||||
|
||||
// ========================= 新增 =========================
|
||||
|
||||
/**
|
||||
* 新增PDI检测规则
|
||||
*/
|
||||
@Transactional
|
||||
public void add(QmsPdiDetectionRulesAddQO request) {
|
||||
String operator = UserUtil.getUserName();
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
|
||||
// 计算版本号(取已有相同 machineNo+inspectionType+orderNo 中的最大版本,若无则 v1)
|
||||
String version = calcVersion(request.getMachineNo(), request.getInspectionType(), request.getOrderNo(), null);
|
||||
|
||||
QmsPdiDetectionRules entity = new QmsPdiDetectionRules()
|
||||
.setRuleNo(basdeSerialNumberControllerService.generateSerialNumber(33))
|
||||
.setMachineNo(request.getMachineNo())
|
||||
.setOrderNo(request.getOrderNo())
|
||||
.setInspectorId(request.getInspectorId())
|
||||
.setInspectionCycle(request.getInspectionCycle())
|
||||
.setInspectionType(request.getInspectionType())
|
||||
.setInspectionVersion(version)
|
||||
.setMaintenanceEnable(false)
|
||||
.setEnable(false)
|
||||
.setPublishEnable(false)
|
||||
.setCreateBy(operator)
|
||||
.setCreateTime(now)
|
||||
.setUpdateBy(operator)
|
||||
.setUpdateTime(now);
|
||||
|
||||
pdiDetectionRulesService.save(entity);
|
||||
}
|
||||
|
||||
// ========================= 编辑 =========================
|
||||
|
||||
/**
|
||||
* 编辑PDI检测规则
|
||||
*/
|
||||
@Transactional
|
||||
public void update(QmsPdiDetectionRulesUpdateQO request) {
|
||||
QmsPdiDetectionRules existing = pdiDetectionRulesService.getById(request.getId());
|
||||
if (Objects.isNull(existing)) {
|
||||
throw new NflgException(STATE.BusinessError, "PDI检测规则不存在");
|
||||
}
|
||||
|
||||
// 用修改后的值(有则用新值,无则用原值)计算版本号
|
||||
String machineNo = StrUtil.isNotBlank(request.getMachineNo()) ? request.getMachineNo() : existing.getMachineNo();
|
||||
Integer inspectionType = request.getInspectionType() != null ? request.getInspectionType() : existing.getInspectionType();
|
||||
String orderNo = StrUtil.isNotBlank(request.getOrderNo()) ? request.getOrderNo() : existing.getOrderNo();
|
||||
|
||||
String version = calcVersion(machineNo, inspectionType, orderNo, request.getId());
|
||||
|
||||
String operator = UserUtil.getUserName();
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
|
||||
pdiDetectionRulesService.lambdaUpdate()
|
||||
.eq(QmsPdiDetectionRules::getId, request.getId())
|
||||
.set(StrUtil.isNotBlank(request.getMachineNo()), QmsPdiDetectionRules::getMachineNo, request.getMachineNo())
|
||||
.set(request.getInspectorId() != null, QmsPdiDetectionRules::getInspectorId, request.getInspectorId())
|
||||
.set(request.getInspectionCycle() != null, QmsPdiDetectionRules::getInspectionCycle, request.getInspectionCycle())
|
||||
.set(request.getInspectionType() != null, QmsPdiDetectionRules::getInspectionType, request.getInspectionType())
|
||||
.set(StrUtil.isNotBlank(request.getOrderNo()), QmsPdiDetectionRules::getOrderNo, request.getOrderNo())
|
||||
.set(QmsPdiDetectionRules::getInspectionVersion, version)
|
||||
.set(QmsPdiDetectionRules::getUpdateBy, operator)
|
||||
.set(QmsPdiDetectionRules::getUpdateTime, now)
|
||||
.update();
|
||||
}
|
||||
|
||||
// ========================= 删除 =========================
|
||||
|
||||
/**
|
||||
* 删除PDI检测规则
|
||||
* 已发布不可删除,未发布且已启用不可删除
|
||||
*/
|
||||
@Transactional
|
||||
public void delete(Long id) {
|
||||
QmsPdiDetectionRules existing = pdiDetectionRulesService.getById(id);
|
||||
if (Objects.isNull(existing)) {
|
||||
throw new NflgException(STATE.BusinessError, "PDI检测规则不存在");
|
||||
}
|
||||
if (Boolean.TRUE.equals(existing.getPublishEnable())) {
|
||||
throw new NflgException(STATE.BusinessError, "已发布的规则不允许删除");
|
||||
}
|
||||
if (Boolean.TRUE.equals(existing.getEnable())) {
|
||||
throw new NflgException(STATE.BusinessError, "未发布且已启用的规则不允许删除,请先禁用后再删除");
|
||||
}
|
||||
pdiDetectionRulesService.removeById(id);
|
||||
}
|
||||
|
||||
// ========================= 发布 =========================
|
||||
|
||||
/**
|
||||
* 批量发布PDI检测规则
|
||||
* 禁用或未维护不允许发布
|
||||
*/
|
||||
@Transactional
|
||||
public void publish(List<Long> ids) {
|
||||
List<QmsPdiDetectionRules> list = pdiDetectionRulesService.listByIds(ids);
|
||||
for (QmsPdiDetectionRules rule : list) {
|
||||
if (Boolean.FALSE.equals(rule.getEnable())) {
|
||||
throw new NflgException(STATE.BusinessError, "规则【" + rule.getRuleNo() + "】处于禁用状态,不允许发布");
|
||||
}
|
||||
if (Boolean.FALSE.equals(rule.getMaintenanceEnable())) {
|
||||
throw new NflgException(STATE.BusinessError, "规则【" + rule.getRuleNo() + "】未维护,不允许发布");
|
||||
}
|
||||
}
|
||||
String operator = UserUtil.getUserName();
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
Pattern pattern = Pattern.compile("^v(\\d+)$");
|
||||
// 逐条更新,重新查同组最大版本号,有则 +1,无则保持 v1
|
||||
for (QmsPdiDetectionRules rule : list) {
|
||||
List<QmsPdiDetectionRules> sameGroup = pdiDetectionRulesService.lambdaQuery()
|
||||
.eq(QmsPdiDetectionRules::getMachineNo, rule.getMachineNo())
|
||||
.eq(QmsPdiDetectionRules::getInspectionType, rule.getInspectionType())
|
||||
.eq(QmsPdiDetectionRules::getOrderNo, rule.getOrderNo())
|
||||
.ne(QmsPdiDetectionRules::getId, rule.getId())
|
||||
.list();
|
||||
String newVersion;
|
||||
if (sameGroup.isEmpty()) {
|
||||
// 库中无同组其他记录,保持 v1
|
||||
newVersion = "v1";
|
||||
} else {
|
||||
// 取同组最大版本号 +1
|
||||
int maxNum = sameGroup.stream()
|
||||
.map(QmsPdiDetectionRules::getInspectionVersion)
|
||||
.filter(v -> v != null)
|
||||
.map(v -> {
|
||||
Matcher m = pattern.matcher(v);
|
||||
return m.matches() ? Integer.parseInt(m.group(1)) : 0;
|
||||
})
|
||||
.max(Comparator.naturalOrder())
|
||||
.orElse(0);
|
||||
newVersion = "v" + (maxNum + 1);
|
||||
}
|
||||
pdiDetectionRulesService.lambdaUpdate()
|
||||
.eq(QmsPdiDetectionRules::getId, rule.getId())
|
||||
.set(QmsPdiDetectionRules::getInspectionVersion, newVersion)
|
||||
.set(QmsPdiDetectionRules::getPublishEnable, true)
|
||||
.set(QmsPdiDetectionRules::getPublishBy, operator)
|
||||
.set(QmsPdiDetectionRules::getPublishTime, now)
|
||||
.set(QmsPdiDetectionRules::getUpdateBy, operator)
|
||||
.set(QmsPdiDetectionRules::getUpdateTime, now)
|
||||
.update();
|
||||
}
|
||||
}
|
||||
|
||||
// ========================= 查询 =========================
|
||||
|
||||
/**
|
||||
* 分页查询PDI检测规则
|
||||
*/
|
||||
public PageData<QmsPdiDetectionRulesVO> search(QmsPdiDetectionRulesSearchQO request) {
|
||||
var page = pdiDetectionRulesMapper.searchPage(
|
||||
request, new Page<>(request.getPage(), request.getPageSize()));
|
||||
|
||||
PageData<QmsPdiDetectionRulesVO> result = new PageData<>();
|
||||
result.setPage(request.getPage());
|
||||
result.setPageSize(request.getPageSize());
|
||||
result.setTotal((int) page.getTotal());
|
||||
result.setItems(page.getRecords());
|
||||
return result;
|
||||
}
|
||||
|
||||
// ========================= 导出机型 =========================
|
||||
|
||||
/**
|
||||
* 导出机型(ids为空则全量导出)
|
||||
*/
|
||||
public void exportMachine(HttpServletResponse response, List<Long> ids) throws IOException {
|
||||
List<QmsPdiMachineExportDTO> data = pdiDetectionRulesMapper.listMachineForExport(
|
||||
(ids != null && !ids.isEmpty()) ? ids : null);
|
||||
EecExcelUtil.export("PDI机型导出", "机型列表", data, response);
|
||||
}
|
||||
|
||||
// ========================= 导入机型 =========================
|
||||
|
||||
/**
|
||||
* 导入机型(批量新增PDI检测规则)
|
||||
* 每行数据自动生成规则编号和版本号,必填字段:机型编号、销售订单号、检测类型、检测周期、质检员ID
|
||||
*/
|
||||
@Transactional
|
||||
public void importMachine(MultipartFile file) throws IOException {
|
||||
List<QmsPdiMachineImportDTO> data = EecExcelUtil.readTo(file.getInputStream(), QmsPdiMachineImportDTO.class);
|
||||
if (CollectionUtil.isEmpty(data)) {
|
||||
throw new NflgException(STATE.BusinessError, "导入文件内容为空");
|
||||
}
|
||||
String operator = UserUtil.getUserName();
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
for (QmsPdiMachineImportDTO dto : data) {
|
||||
// 校验必填字段
|
||||
if (StrUtil.isBlank(dto.getMachineNo()) || StrUtil.isBlank(dto.getOrderNo())
|
||||
|| dto.getInspectionType() == null || dto.getInspectionCycle() == null
|
||||
|| dto.getInspectorId() == null) {
|
||||
throw new NflgException(STATE.BusinessError,
|
||||
"导入数据存在必填字段为空(机型编号、销售订单号、检测类型、检测周期、质检员ID),请检查文件");
|
||||
}
|
||||
String version = calcVersion(dto.getMachineNo(), dto.getInspectionType(), dto.getOrderNo(), null);
|
||||
QmsPdiDetectionRules entity = new QmsPdiDetectionRules()
|
||||
.setRuleNo(basdeSerialNumberControllerService.generateSerialNumber(33))
|
||||
.setMachineNo(dto.getMachineNo())
|
||||
.setOrderNo(dto.getOrderNo())
|
||||
.setInspectorId(dto.getInspectorId())
|
||||
.setInspectionCycle(dto.getInspectionCycle())
|
||||
.setInspectionType(dto.getInspectionType())
|
||||
.setInspectionVersion(version)
|
||||
.setMaintenanceEnable(false)
|
||||
.setEnable(false)
|
||||
.setPublishEnable(false)
|
||||
.setCreateBy(operator)
|
||||
.setCreateTime(now)
|
||||
.setUpdateBy(operator)
|
||||
.setUpdateTime(now);
|
||||
pdiDetectionRulesService.save(entity);
|
||||
}
|
||||
}
|
||||
|
||||
// ========================= 导出 =========================
|
||||
|
||||
/**
|
||||
* 导出PDI检测规则(ids为空则全量导出)
|
||||
*/
|
||||
public void export(HttpServletResponse response, List<Long> ids) throws IOException {
|
||||
List<QmsPdiDetectionRulesExportDTO> data = pdiDetectionRulesMapper.listForExport(
|
||||
(ids != null && !ids.isEmpty()) ? ids : null);
|
||||
EecExcelUtil.export("PDI检测规则导出", "检测规则列表", data, response);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,197 @@
|
|||
package com.nflg.qms.admin.service;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.nflg.wms.common.exception.NflgException;
|
||||
import com.nflg.wms.common.constant.STATE;
|
||||
import com.nflg.wms.common.pojo.dto.QmsPdiStatusItemExportDTO;
|
||||
import com.nflg.wms.common.pojo.dto.QmsPdiStatusItemImportDTO;
|
||||
import com.nflg.wms.common.pojo.qo.QmsPdiStatusItemAddQO;
|
||||
import com.nflg.wms.common.pojo.qo.QmsPdiStatusItemUpdateQO;
|
||||
import com.nflg.wms.common.pojo.vo.QmsPdiStatusItemGroupVO;
|
||||
import com.nflg.wms.common.util.EecExcelUtil;
|
||||
import com.nflg.wms.common.util.UserUtil;
|
||||
import com.nflg.wms.repository.entity.QmsPdiDetectionRulesStatusItem;
|
||||
import com.nflg.wms.repository.mapper.QmsPdiDetectionRulesStatusItemMapper;
|
||||
import com.nflg.wms.repository.service.IQmsPdiDetectionRulesStatusItemService;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* PDI动静态检测项 ControllerService
|
||||
*/
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class QmsPdiStatusItemControllerService {
|
||||
|
||||
private final IQmsPdiDetectionRulesStatusItemService statusItemService;
|
||||
private final QmsPdiDetectionRulesStatusItemMapper statusItemMapper;
|
||||
|
||||
// ========================= 新增 =========================
|
||||
|
||||
/**
|
||||
* 新增PDI检测项
|
||||
*/
|
||||
@Transactional
|
||||
public void add(QmsPdiStatusItemAddQO request) {
|
||||
String operator = UserUtil.getUserName();
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
QmsPdiDetectionRulesStatusItem entity = new QmsPdiDetectionRulesStatusItem()
|
||||
.setDetectionRulesId(request.getDetectionRulesId())
|
||||
.setComponentsDes(request.getComponentsDes())
|
||||
.setInspectionContent(request.getInspectionContent())
|
||||
.setInspectionImage(request.getInspectionImage())
|
||||
.setStatus(request.getStatus())
|
||||
.setSetBy(operator)
|
||||
.setSetTime(now);
|
||||
statusItemService.save(entity);
|
||||
}
|
||||
|
||||
// ========================= 修改 =========================
|
||||
|
||||
/**
|
||||
* 修改PDI检测项(仅更新非空字段)
|
||||
*/
|
||||
@Transactional
|
||||
public void update(QmsPdiStatusItemUpdateQO request) {
|
||||
QmsPdiDetectionRulesStatusItem existing = statusItemService.getById(request.getId());
|
||||
if (Objects.isNull(existing)) {
|
||||
throw new NflgException(STATE.BusinessError, "检测项不存在");
|
||||
}
|
||||
String operator = UserUtil.getUserName();
|
||||
var updateChain = statusItemService.lambdaUpdate()
|
||||
.eq(QmsPdiDetectionRulesStatusItem::getId, request.getId())
|
||||
.set(QmsPdiDetectionRulesStatusItem::getSetBy, operator)
|
||||
.set(QmsPdiDetectionRulesStatusItem::getSetTime, LocalDateTime.now());
|
||||
if (StrUtil.isNotBlank(request.getComponentsDes())) {
|
||||
updateChain.set(QmsPdiDetectionRulesStatusItem::getComponentsDes, request.getComponentsDes());
|
||||
}
|
||||
if (StrUtil.isNotBlank(request.getInspectionContent())) {
|
||||
updateChain.set(QmsPdiDetectionRulesStatusItem::getInspectionContent, request.getInspectionContent());
|
||||
}
|
||||
if (StrUtil.isNotBlank(request.getInspectionImage())) {
|
||||
updateChain.set(QmsPdiDetectionRulesStatusItem::getInspectionImage, request.getInspectionImage());
|
||||
}
|
||||
updateChain.update();
|
||||
}
|
||||
|
||||
// ========================= 删除 =========================
|
||||
|
||||
/**
|
||||
* 删除PDI检测项
|
||||
*/
|
||||
@Transactional
|
||||
public void delete(Long id) {
|
||||
QmsPdiDetectionRulesStatusItem existing = statusItemService.getById(id);
|
||||
if (Objects.isNull(existing)) {
|
||||
throw new NflgException(STATE.BusinessError, "检测项不存在");
|
||||
}
|
||||
statusItemService.removeById(id);
|
||||
}
|
||||
|
||||
// ========================= 导出 =========================
|
||||
|
||||
/**
|
||||
* 导出PDI检测项
|
||||
* 如果ids不为空则导出指定ID数据,否则导出同状态全量数据
|
||||
*/
|
||||
public void export(HttpServletResponse response, List<Long> ids, Long detectionRulesId, Integer status) throws IOException {
|
||||
List<QmsPdiStatusItemExportDTO> data = statusItemMapper.listForExport(ids, detectionRulesId, status);
|
||||
String statusName = status == 0 ? "静态" : "动态";
|
||||
EecExcelUtil.export("PDI" + statusName + "检测项", "PDI" + statusName + "检测项", data, response);
|
||||
}
|
||||
|
||||
// ========================= 下载导入模板 =========================
|
||||
|
||||
/**
|
||||
* 下载导入模板
|
||||
*/
|
||||
public void downloadTemplate(HttpServletResponse response) throws IOException {
|
||||
QmsPdiStatusItemImportDTO example = new QmsPdiStatusItemImportDTO()
|
||||
.setComponentsDes("示例部件描述")
|
||||
.setInspectionContent("示例检查核实内容")
|
||||
.setInspectionImage("示例检测示例图URL");
|
||||
EecExcelUtil.export("PDI检测项导入模板", "PDI检测项导入模板", List.of(example), response);
|
||||
}
|
||||
|
||||
// ========================= 导入 =========================
|
||||
|
||||
/**
|
||||
* 导入PDI检测项
|
||||
*/
|
||||
@Transactional
|
||||
public void importFromExcel(MultipartFile file, Long detectionRulesId, Integer status) throws IOException {
|
||||
List<QmsPdiStatusItemImportDTO> data = EecExcelUtil.readTo(file.getInputStream(), QmsPdiStatusItemImportDTO.class);
|
||||
if (CollectionUtil.isEmpty(data)) {
|
||||
throw new NflgException(STATE.BusinessError, "导入文件内容为空");
|
||||
}
|
||||
String operator = UserUtil.getUserName();
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
List<QmsPdiDetectionRulesStatusItem> entities = data.stream()
|
||||
.filter(dto -> StrUtil.isNotBlank(dto.getComponentsDes()) && StrUtil.isNotBlank(dto.getInspectionContent()))
|
||||
.map(dto -> new QmsPdiDetectionRulesStatusItem()
|
||||
.setDetectionRulesId(detectionRulesId)
|
||||
.setComponentsDes(dto.getComponentsDes())
|
||||
.setInspectionContent(dto.getInspectionContent())
|
||||
.setInspectionImage(dto.getInspectionImage())
|
||||
.setStatus(status)
|
||||
.setSetBy(operator)
|
||||
.setSetTime(now))
|
||||
.collect(Collectors.toList());
|
||||
if (CollectionUtil.isEmpty(entities)) {
|
||||
throw new NflgException(STATE.BusinessError, "导入数据中必填字段(部件描述、检查核实内容)均为空,请检查文件");
|
||||
}
|
||||
statusItemService.saveBatch(entities);
|
||||
}
|
||||
|
||||
// ========================= 分页查询 =========================
|
||||
|
||||
/**
|
||||
* 查询PDI检测项,按状态分组返回
|
||||
*
|
||||
* @param detectionRulesId PDI检测规则ID(必传)
|
||||
*/
|
||||
public QmsPdiStatusItemGroupVO search(Long detectionRulesId) {
|
||||
List<QmsPdiDetectionRulesStatusItem> all = statusItemService.lambdaQuery()
|
||||
.eq(QmsPdiDetectionRulesStatusItem::getDetectionRulesId, detectionRulesId)
|
||||
.orderByAsc(QmsPdiDetectionRulesStatusItem::getId)
|
||||
.list();
|
||||
|
||||
List<QmsPdiStatusItemGroupVO.QmsPdiStatusItemVO> staticList = all.stream()
|
||||
.filter(item -> Objects.equals(item.getStatus(), 0))
|
||||
.map(this::toVO)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<QmsPdiStatusItemGroupVO.QmsPdiStatusItemVO> dynamicList = all.stream()
|
||||
.filter(item -> Objects.equals(item.getStatus(), 1))
|
||||
.map(this::toVO)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
QmsPdiStatusItemGroupVO vo = new QmsPdiStatusItemGroupVO();
|
||||
vo.setStaticItems(staticList);
|
||||
vo.setDynamicItems(dynamicList);
|
||||
return vo;
|
||||
}
|
||||
|
||||
private QmsPdiStatusItemGroupVO.QmsPdiStatusItemVO toVO(QmsPdiDetectionRulesStatusItem item) {
|
||||
QmsPdiStatusItemGroupVO.QmsPdiStatusItemVO vo = new QmsPdiStatusItemGroupVO.QmsPdiStatusItemVO();
|
||||
vo.setId(item.getId());
|
||||
vo.setDetectionRulesId(item.getDetectionRulesId());
|
||||
vo.setComponentsDes(item.getComponentsDes());
|
||||
vo.setInspectionContent(item.getInspectionContent());
|
||||
vo.setInspectionImage(item.getInspectionImage());
|
||||
vo.setStatus(item.getStatus());
|
||||
vo.setSetBy(item.getSetBy());
|
||||
vo.setSetTime(item.getSetTime());
|
||||
return vo;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
package com.nflg.wms.common.pojo.dto;
|
||||
|
||||
import org.ttzero.excel.annotation.ExcelColumn;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* PDI检测规则 导出DTO
|
||||
*/
|
||||
@Data
|
||||
public class QmsPdiDetectionRulesExportDTO {
|
||||
|
||||
@ExcelColumn("规则编号")
|
||||
private String ruleNo;
|
||||
|
||||
@ExcelColumn("机型编号")
|
||||
private String machineNo;
|
||||
|
||||
@ExcelColumn("销售订单号")
|
||||
private String orderNo;
|
||||
|
||||
@ExcelColumn("质检员")
|
||||
private String inspectorName;
|
||||
|
||||
@ExcelColumn("检测周期")
|
||||
private Integer inspectionCycle;
|
||||
|
||||
@ExcelColumn("检测类型")
|
||||
private String inspectionTypeName;
|
||||
|
||||
@ExcelColumn("检测版本号")
|
||||
private String inspectionVersion;
|
||||
|
||||
@ExcelColumn("维护状态")
|
||||
private String maintenanceEnableName;
|
||||
|
||||
@ExcelColumn("启用状态")
|
||||
private String enableName;
|
||||
|
||||
@ExcelColumn("发布状态")
|
||||
private String publishEnableName;
|
||||
|
||||
@ExcelColumn("发布人")
|
||||
private String publishBy;
|
||||
|
||||
@ExcelColumn("发布时间")
|
||||
private LocalDateTime publishTime;
|
||||
|
||||
@ExcelColumn("创建人")
|
||||
private String createBy;
|
||||
|
||||
@ExcelColumn("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
package com.nflg.wms.common.pojo.dto;
|
||||
|
||||
import org.ttzero.excel.annotation.ExcelColumn;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* PDI机型 导出DTO
|
||||
*/
|
||||
@Data
|
||||
public class QmsPdiMachineExportDTO {
|
||||
|
||||
@ExcelColumn("机型编号")
|
||||
private String machineNo;
|
||||
|
||||
@ExcelColumn("销售订单号")
|
||||
private String orderNo;
|
||||
|
||||
@ExcelColumn("检测类型")
|
||||
private String inspectionTypeName;
|
||||
|
||||
@ExcelColumn("检测版本号")
|
||||
private String inspectionVersion;
|
||||
|
||||
@ExcelColumn("发布状态")
|
||||
private String publishEnableName;
|
||||
}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
package com.nflg.wms.common.pojo.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.ttzero.excel.annotation.ExcelColumn;
|
||||
|
||||
/**
|
||||
* PDI机型 导入DTO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class QmsPdiMachineImportDTO {
|
||||
|
||||
/**
|
||||
* 机型编号
|
||||
*/
|
||||
@ExcelColumn("*机型编号")
|
||||
private String machineNo;
|
||||
|
||||
/**
|
||||
* 销售订单号
|
||||
*/
|
||||
@ExcelColumn("*销售订单号")
|
||||
private String orderNo;
|
||||
|
||||
/**
|
||||
* 检测类型(0=新机检测,1=库存检测)
|
||||
*/
|
||||
@ExcelColumn("*检测类型(0=新机检测,1=库存检测)")
|
||||
private Integer inspectionType;
|
||||
|
||||
/**
|
||||
* 检测周期
|
||||
*/
|
||||
@ExcelColumn("*检测周期")
|
||||
private Integer inspectionCycle;
|
||||
|
||||
/**
|
||||
* 质检员ID
|
||||
*/
|
||||
@ExcelColumn("*质检员ID")
|
||||
private Long inspectorId;
|
||||
|
||||
/**
|
||||
* 错误信息
|
||||
*/
|
||||
@ExcelColumn("错误信息")
|
||||
private String error;
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
package com.nflg.wms.common.pojo.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.ttzero.excel.annotation.ExcelColumn;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* PDI动静态检测项 导出DTO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class QmsPdiStatusItemExportDTO {
|
||||
|
||||
@ExcelColumn("部件描述")
|
||||
private String componentsDes;
|
||||
|
||||
@ExcelColumn("检查核实内容")
|
||||
private String inspectionContent;
|
||||
|
||||
@ExcelColumn("检测示例图")
|
||||
private String inspectionImage;
|
||||
|
||||
@ExcelColumn("状态")
|
||||
private String statusName;
|
||||
|
||||
@ExcelColumn("设置人")
|
||||
private String setBy;
|
||||
|
||||
@ExcelColumn("设置时间")
|
||||
private LocalDateTime setTime;
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
package com.nflg.wms.common.pojo.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.ttzero.excel.annotation.ExcelColumn;
|
||||
|
||||
/**
|
||||
* PDI动静态检测项 导出/导入DTO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class QmsPdiStatusItemImportDTO {
|
||||
|
||||
/**
|
||||
* 部件描述
|
||||
*/
|
||||
@ExcelColumn("*部件描述")
|
||||
private String componentsDes;
|
||||
|
||||
/**
|
||||
* 检查核实内容
|
||||
*/
|
||||
@ExcelColumn("*检查核实内容")
|
||||
private String inspectionContent;
|
||||
|
||||
/**
|
||||
* 检测示例图
|
||||
*/
|
||||
@ExcelColumn("检测示例图")
|
||||
private String inspectionImage;
|
||||
|
||||
/**
|
||||
* 错误信息
|
||||
*/
|
||||
@ExcelColumn("错误信息")
|
||||
private String error;
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
package com.nflg.wms.common.pojo.qo;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* PDI检测规则 新增请求参数
|
||||
*/
|
||||
@Data
|
||||
public class QmsPdiDetectionRulesAddQO {
|
||||
|
||||
/**
|
||||
* 机型编号(必传)
|
||||
*/
|
||||
@NotBlank(message = "机型编号不能为空")
|
||||
private String machineNo;
|
||||
|
||||
/**
|
||||
* 质检负责人id(user.id,必传)
|
||||
*/
|
||||
@NotNull(message = "质检负责人ID不能为空")
|
||||
private Long inspectorId;
|
||||
|
||||
/**
|
||||
* 检测周期(必传)
|
||||
*/
|
||||
@NotNull(message = "检测周期不能为空")
|
||||
private Integer inspectionCycle;
|
||||
|
||||
/**
|
||||
* 检测类型:0为新机检测,1为库存检测(必传)
|
||||
*/
|
||||
@NotNull(message = "检测类型不能为空")
|
||||
private Integer inspectionType;
|
||||
|
||||
/**
|
||||
* 销售订单号(必传)
|
||||
*/
|
||||
@NotBlank(message = "销售订单号不能为空")
|
||||
private String orderNo;
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
package com.nflg.wms.common.pojo.qo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* PDI检测规则 分页查询请求参数
|
||||
*/
|
||||
@Data
|
||||
public class QmsPdiDetectionRulesSearchQO {
|
||||
|
||||
/**
|
||||
* 机型编号(可选)
|
||||
*/
|
||||
private String machineNo;
|
||||
|
||||
/**
|
||||
* 销售订单号(可选)
|
||||
*/
|
||||
private String orderNo;
|
||||
|
||||
/**
|
||||
* 发布日期区间-开始(可选)
|
||||
*/
|
||||
private LocalDateTime publishTimeStart;
|
||||
|
||||
/**
|
||||
* 发布日期区间-结束(可选)
|
||||
*/
|
||||
private LocalDateTime publishTimeEnd;
|
||||
|
||||
/**
|
||||
* 页码
|
||||
*/
|
||||
private Integer page = 1;
|
||||
|
||||
/**
|
||||
* 每页条数
|
||||
*/
|
||||
private Integer pageSize = 10;
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
package com.nflg.wms.common.pojo.qo;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* PDI检测规则 编辑请求参数
|
||||
*/
|
||||
@Data
|
||||
public class QmsPdiDetectionRulesUpdateQO {
|
||||
|
||||
/**
|
||||
* 规则ID(必传)
|
||||
*/
|
||||
@NotNull(message = "ID不能为空")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 机型编号(可选)
|
||||
*/
|
||||
private String machineNo;
|
||||
|
||||
/**
|
||||
* 质检负责人id(user.id,可选)
|
||||
*/
|
||||
private Long inspectorId;
|
||||
|
||||
/**
|
||||
* 检测周期(可选)
|
||||
*/
|
||||
private Integer inspectionCycle;
|
||||
|
||||
/**
|
||||
* 检测类型:0为新机检测,1为库存检测(可选)
|
||||
*/
|
||||
private Integer inspectionType;
|
||||
|
||||
/**
|
||||
* 销售订单号(可选)
|
||||
*/
|
||||
private String orderNo;
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
package com.nflg.wms.common.pojo.qo;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* PDI动静态检测项 新增请求参数
|
||||
*/
|
||||
@Data
|
||||
public class QmsPdiStatusItemAddQO {
|
||||
|
||||
/**
|
||||
* PDI检测规则ID(必传)
|
||||
*/
|
||||
@NotNull(message = "PDI检测规则ID不能为空")
|
||||
private Long detectionRulesId;
|
||||
|
||||
/**
|
||||
* 部件描述(必传)
|
||||
*/
|
||||
@NotBlank(message = "部件描述不能为空")
|
||||
private String componentsDes;
|
||||
|
||||
/**
|
||||
* 检查核实内容(必传)
|
||||
*/
|
||||
@NotBlank(message = "检查核实内容不能为空")
|
||||
private String inspectionContent;
|
||||
|
||||
/**
|
||||
* 检测示例图(必传)
|
||||
*/
|
||||
@NotBlank(message = "检测示例图不能为空")
|
||||
private String inspectionImage;
|
||||
|
||||
/**
|
||||
* 状态:0为静态,1为动态(必传)
|
||||
*/
|
||||
@NotNull(message = "状态不能为空")
|
||||
private Integer status;
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
package com.nflg.wms.common.pojo.qo;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* PDI动静态检测项 修改请求参数
|
||||
*/
|
||||
@Data
|
||||
public class QmsPdiStatusItemUpdateQO {
|
||||
|
||||
/**
|
||||
* ID(必传)
|
||||
*/
|
||||
@NotNull(message = "ID不能为空")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 部件描述(可选)
|
||||
*/
|
||||
private String componentsDes;
|
||||
|
||||
/**
|
||||
* 检查核实内容(可选)
|
||||
*/
|
||||
private String inspectionContent;
|
||||
|
||||
/**
|
||||
* 检测示例图(可选)
|
||||
*/
|
||||
private String inspectionImage;
|
||||
}
|
||||
|
|
@ -0,0 +1,99 @@
|
|||
package com.nflg.wms.common.pojo.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* PDI检测规则 列表/详情VO
|
||||
*/
|
||||
@Data
|
||||
public class QmsPdiDetectionRulesVO {
|
||||
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 规则编号
|
||||
*/
|
||||
private String ruleNo;
|
||||
|
||||
/**
|
||||
* 机型编号
|
||||
*/
|
||||
private String machineNo;
|
||||
|
||||
/**
|
||||
* 销售订单号
|
||||
*/
|
||||
private String orderNo;
|
||||
|
||||
/**
|
||||
* 质检员id
|
||||
*/
|
||||
private Long inspectorId;
|
||||
|
||||
/**
|
||||
* 质检员姓名
|
||||
*/
|
||||
private String inspectorName;
|
||||
|
||||
/**
|
||||
* 检测周期
|
||||
*/
|
||||
private Integer inspectionCycle;
|
||||
|
||||
/**
|
||||
* 检测类型:0为新机检测,1为库存检测
|
||||
*/
|
||||
private Integer inspectionType;
|
||||
|
||||
/**
|
||||
* 检测版本号
|
||||
*/
|
||||
private String inspectionVersion;
|
||||
|
||||
/**
|
||||
* 维护状态:true为已维护,false为未维护
|
||||
*/
|
||||
private Boolean maintenanceEnable;
|
||||
|
||||
/**
|
||||
* 状态:true为已启用,false为未启用
|
||||
*/
|
||||
private Boolean enable;
|
||||
|
||||
/**
|
||||
* 发布状态:true为已发布,false为未发布
|
||||
*/
|
||||
private Boolean publishEnable;
|
||||
|
||||
/**
|
||||
* 发布人
|
||||
*/
|
||||
private String publishBy;
|
||||
|
||||
/**
|
||||
* 发布时间
|
||||
*/
|
||||
private LocalDateTime publishTime;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
}
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
package com.nflg.wms.common.pojo.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* PDI动静态检测项 分页查询返回VO(按状态分组)
|
||||
*/
|
||||
@Data
|
||||
public class QmsPdiStatusItemGroupVO {
|
||||
|
||||
/**
|
||||
* 静态检测项列表(status=0)
|
||||
*/
|
||||
private List<QmsPdiStatusItemVO> staticItems;
|
||||
|
||||
/**
|
||||
* 动态检测项列表(status=1)
|
||||
*/
|
||||
private List<QmsPdiStatusItemVO> dynamicItems;
|
||||
|
||||
@Data
|
||||
public static class QmsPdiStatusItemVO {
|
||||
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* PDI检测规则ID
|
||||
*/
|
||||
private Long detectionRulesId;
|
||||
|
||||
/**
|
||||
* 部件描述
|
||||
*/
|
||||
private String componentsDes;
|
||||
|
||||
/**
|
||||
* 检查核实内容
|
||||
*/
|
||||
private String inspectionContent;
|
||||
|
||||
/**
|
||||
* 检测示例图
|
||||
*/
|
||||
private String inspectionImage;
|
||||
|
||||
/**
|
||||
* 状态:0为静态,1为动态
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 设置人
|
||||
*/
|
||||
private String setBy;
|
||||
|
||||
/**
|
||||
* 设置时间
|
||||
*/
|
||||
private LocalDateTime setTime;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,108 @@
|
|||
package com.nflg.wms.repository.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* PDI检测规则
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@Accessors(chain = true)
|
||||
@TableName("qms_pdi_detection_rules")
|
||||
public class QmsPdiDetectionRules implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "id", type = IdType.ASSIGN_ID)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 规则编号
|
||||
*/
|
||||
private String ruleNo;
|
||||
|
||||
/**
|
||||
* 机型编号
|
||||
*/
|
||||
private String machineNo;
|
||||
|
||||
/**
|
||||
* 销售订单号
|
||||
*/
|
||||
private String orderNo;
|
||||
|
||||
/**
|
||||
* 质检员id(user.id)
|
||||
*/
|
||||
private Long inspectorId;
|
||||
|
||||
/**
|
||||
* 检测周期
|
||||
*/
|
||||
private Integer inspectionCycle;
|
||||
|
||||
/**
|
||||
* 检测类型:0为新机检测,1为库存检测
|
||||
*/
|
||||
private Integer inspectionType;
|
||||
|
||||
/**
|
||||
* 检测版本号(如 v1、v2)
|
||||
*/
|
||||
private String inspectionVersion;
|
||||
|
||||
/**
|
||||
* 维护状态:true为已维护,false为未维护
|
||||
*/
|
||||
private Boolean maintenanceEnable;
|
||||
|
||||
/**
|
||||
* 状态:true为已启用,false为未启用
|
||||
*/
|
||||
private Boolean enable;
|
||||
|
||||
/**
|
||||
* 发布状态:true为已发布,false为未发布
|
||||
*/
|
||||
private Boolean publishEnable;
|
||||
|
||||
/**
|
||||
* 发布人
|
||||
*/
|
||||
private String publishBy;
|
||||
|
||||
/**
|
||||
* 发布时间
|
||||
*/
|
||||
private LocalDateTime publishTime;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
}
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
package com.nflg.wms.repository.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* PDI动静态检测项
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@Accessors(chain = true)
|
||||
@TableName("qms_pdi_detection_rules_status_item")
|
||||
public class QmsPdiDetectionRulesStatusItem implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "id", type = IdType.ASSIGN_ID)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* PDI检测规则ID
|
||||
*/
|
||||
private Long detectionRulesId;
|
||||
|
||||
/**
|
||||
* 部件描述
|
||||
*/
|
||||
private String componentsDes;
|
||||
|
||||
/**
|
||||
* 检查核实内容
|
||||
*/
|
||||
private String inspectionContent;
|
||||
|
||||
/**
|
||||
* 检测示例图
|
||||
*/
|
||||
private String inspectionImage;
|
||||
|
||||
/**
|
||||
* 状态:0为静态,1为动态
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 设置人
|
||||
*/
|
||||
private String setBy;
|
||||
|
||||
/**
|
||||
* 设置时间
|
||||
*/
|
||||
private LocalDateTime setTime;
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
package com.nflg.wms.repository.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.nflg.wms.common.pojo.qo.QmsPdiDetectionRulesSearchQO;
|
||||
import com.nflg.wms.common.pojo.vo.QmsPdiDetectionRulesVO;
|
||||
import com.nflg.wms.common.pojo.dto.QmsPdiDetectionRulesExportDTO;
|
||||
import com.nflg.wms.common.pojo.dto.QmsPdiMachineExportDTO;
|
||||
import com.nflg.wms.repository.entity.QmsPdiDetectionRules;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* PDI检测规则 Mapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface QmsPdiDetectionRulesMapper extends BaseMapper<QmsPdiDetectionRules> {
|
||||
|
||||
/**
|
||||
* 分页查询PDI检测规则
|
||||
*/
|
||||
IPage<QmsPdiDetectionRulesVO> searchPage(@Param("qo") QmsPdiDetectionRulesSearchQO qo, Page<QmsPdiDetectionRulesVO> page);
|
||||
|
||||
/**
|
||||
* 导出PDI检测规则
|
||||
*/
|
||||
List<QmsPdiDetectionRulesExportDTO> listForExport(@Param("ids") List<Long> ids);
|
||||
|
||||
/**
|
||||
* 导出机型
|
||||
*/
|
||||
List<QmsPdiMachineExportDTO> listMachineForExport(@Param("ids") List<Long> ids);
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
package com.nflg.wms.repository.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.nflg.wms.common.pojo.dto.QmsPdiStatusItemExportDTO;
|
||||
import com.nflg.wms.repository.entity.QmsPdiDetectionRulesStatusItem;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* PDI动静态检测项 Mapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface QmsPdiDetectionRulesStatusItemMapper extends BaseMapper<QmsPdiDetectionRulesStatusItem> {
|
||||
|
||||
/**
|
||||
* 导出检测项
|
||||
*
|
||||
* @param ids 可选,指定ID列表;为空则按 detectionRulesId + status 全量导出
|
||||
* @param detectionRulesId PDI检测规则ID
|
||||
* @param status 状态(0静态/1动态)
|
||||
*/
|
||||
List<QmsPdiStatusItemExportDTO> listForExport(@Param("ids") List<Long> ids,
|
||||
@Param("detectionRulesId") Long detectionRulesId,
|
||||
@Param("status") Integer status);
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
package com.nflg.wms.repository.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.nflg.wms.repository.entity.QmsPdiDetectionRules;
|
||||
|
||||
/**
|
||||
* PDI检测规则 Service接口
|
||||
*/
|
||||
public interface IQmsPdiDetectionRulesService extends IService<QmsPdiDetectionRules> {
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
package com.nflg.wms.repository.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.nflg.wms.repository.entity.QmsPdiDetectionRulesStatusItem;
|
||||
|
||||
/**
|
||||
* PDI动静态检测项 Service
|
||||
*/
|
||||
public interface IQmsPdiDetectionRulesStatusItemService extends IService<QmsPdiDetectionRulesStatusItem> {
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package com.nflg.wms.repository.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.nflg.wms.repository.entity.QmsPdiDetectionRules;
|
||||
import com.nflg.wms.repository.mapper.QmsPdiDetectionRulesMapper;
|
||||
import com.nflg.wms.repository.service.IQmsPdiDetectionRulesService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* PDI检测规则 服务实现类
|
||||
*/
|
||||
@Service
|
||||
public class QmsPdiDetectionRulesServiceImpl extends ServiceImpl<QmsPdiDetectionRulesMapper, QmsPdiDetectionRules>
|
||||
implements IQmsPdiDetectionRulesService {
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package com.nflg.wms.repository.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.nflg.wms.repository.entity.QmsPdiDetectionRulesStatusItem;
|
||||
import com.nflg.wms.repository.mapper.QmsPdiDetectionRulesStatusItemMapper;
|
||||
import com.nflg.wms.repository.service.IQmsPdiDetectionRulesStatusItemService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* PDI动静态检测项 ServiceImpl
|
||||
*/
|
||||
@Service
|
||||
public class QmsPdiDetectionRulesStatusItemServiceImpl
|
||||
extends ServiceImpl<QmsPdiDetectionRulesStatusItemMapper, QmsPdiDetectionRulesStatusItem>
|
||||
implements IQmsPdiDetectionRulesStatusItemService {
|
||||
}
|
||||
|
|
@ -0,0 +1,95 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.nflg.wms.repository.mapper.QmsPdiDetectionRulesMapper">
|
||||
|
||||
<!-- 分页查询PDI检测规则 -->
|
||||
<select id="searchPage" resultType="com.nflg.wms.common.pojo.vo.QmsPdiDetectionRulesVO">
|
||||
SELECT
|
||||
r.id,
|
||||
r.rule_no,
|
||||
r.machine_no,
|
||||
r.order_no,
|
||||
r.inspector_id,
|
||||
u.user_name AS inspector_name,
|
||||
r.inspection_cycle,
|
||||
r.inspection_type,
|
||||
r.inspection_version,
|
||||
r.maintenance_enable,
|
||||
r.enable,
|
||||
r.publish_enable,
|
||||
r.publish_by,
|
||||
r.publish_time,
|
||||
r.create_by,
|
||||
r.create_time,
|
||||
r.update_by,
|
||||
r.update_time
|
||||
FROM qms_pdi_detection_rules r
|
||||
LEFT JOIN "user" u ON u.id = r.inspector_id
|
||||
<where>
|
||||
<if test="qo.machineNo != null and qo.machineNo != ''">
|
||||
AND r.machine_no = #{qo.machineNo}
|
||||
</if>
|
||||
<if test="qo.orderNo != null and qo.orderNo != ''">
|
||||
AND r.order_no = #{qo.orderNo}
|
||||
</if>
|
||||
<if test="qo.publishTimeStart != null">
|
||||
AND r.publish_time >= #{qo.publishTimeStart}
|
||||
</if>
|
||||
<if test="qo.publishTimeEnd != null">
|
||||
AND r.publish_time <= #{qo.publishTimeEnd}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY r.id DESC
|
||||
</select>
|
||||
|
||||
<!-- 导出PDI检测规则 -->
|
||||
<select id="listForExport" resultType="com.nflg.wms.common.pojo.dto.QmsPdiDetectionRulesExportDTO">
|
||||
SELECT
|
||||
r.rule_no,
|
||||
r.machine_no,
|
||||
r.order_no,
|
||||
u.user_name AS inspector_name,
|
||||
r.inspection_cycle,
|
||||
CASE r.inspection_type WHEN 0 THEN '新机检测' WHEN 1 THEN '库存检测' ELSE '' END AS inspection_type_name,
|
||||
r.inspection_version,
|
||||
CASE r.maintenance_enable WHEN true THEN '已维护' ELSE '未维护' END AS maintenance_enable_name,
|
||||
CASE r.enable WHEN true THEN '已启用' ELSE '未启用' END AS enable_name,
|
||||
CASE r.publish_enable WHEN true THEN '已发布' ELSE '未发布' END AS publish_enable_name,
|
||||
r.publish_by,
|
||||
r.publish_time,
|
||||
r.create_by,
|
||||
r.create_time
|
||||
FROM qms_pdi_detection_rules r
|
||||
LEFT JOIN "user" u ON u.id = r.inspector_id
|
||||
<where>
|
||||
<if test="ids != null and ids.size() > 0">
|
||||
AND r.id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY r.id DESC
|
||||
</select>
|
||||
|
||||
<!-- 导出机型 -->
|
||||
<select id="listMachineForExport" resultType="com.nflg.wms.common.pojo.dto.QmsPdiMachineExportDTO">
|
||||
SELECT
|
||||
r.machine_no,
|
||||
r.order_no,
|
||||
CASE r.inspection_type WHEN 0 THEN '新机检测' WHEN 1 THEN '库存检测' ELSE '' END AS inspection_type_name,
|
||||
r.inspection_version,
|
||||
CASE r.publish_enable WHEN true THEN '已发布' ELSE '未发布' END AS publish_enable_name
|
||||
FROM qms_pdi_detection_rules r
|
||||
<where>
|
||||
<if test="ids != null and ids.size() > 0">
|
||||
AND r.id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY r.id DESC
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.nflg.wms.repository.mapper.QmsPdiDetectionRulesStatusItemMapper">
|
||||
|
||||
<!-- 导出检测项 -->
|
||||
<select id="listForExport" resultType="com.nflg.wms.common.pojo.dto.QmsPdiStatusItemExportDTO">
|
||||
SELECT
|
||||
s.components_des,
|
||||
s.inspection_content,
|
||||
s.inspection_image,
|
||||
CASE s.status WHEN 0 THEN '静态' WHEN 1 THEN '动态' ELSE '' END AS status_name,
|
||||
s.set_by,
|
||||
s.set_time
|
||||
FROM qms_pdi_detection_rules_status_item s
|
||||
WHERE s.detection_rules_id = #{detectionRulesId}
|
||||
AND s.status = #{status}
|
||||
<if test="ids != null and ids.size() > 0">
|
||||
AND s.id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
ORDER BY s.id ASC
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue