pdi检测功能
This commit is contained in:
parent
7acb8f31a0
commit
c8f852ea52
|
|
@ -0,0 +1,60 @@
|
|||
package com.nflg.qms.admin.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.nflg.qms.admin.service.QmsPdiComponentControllerService;
|
||||
import com.nflg.wms.common.pojo.ApiResult;
|
||||
import com.nflg.wms.common.pojo.qo.QmsPdiComponentAddQO;
|
||||
import com.nflg.wms.common.pojo.qo.QmsPdiComponentSearchQO;
|
||||
import com.nflg.wms.common.pojo.qo.QmsPdiComponentUpdateQO;
|
||||
import com.nflg.wms.repository.entity.QmsPdiComponentAnagement;
|
||||
import com.nflg.wms.starter.BaseController;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 部件管理
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/pdiComponent")
|
||||
public class QmsPdiComponentController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private QmsPdiComponentControllerService componentControllerService;
|
||||
|
||||
/**
|
||||
* 新增部件
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
public ApiResult<Void> add(@Valid @RequestBody QmsPdiComponentAddQO request) {
|
||||
componentControllerService.add(request);
|
||||
return ApiResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改部件
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
public ApiResult<Void> update(@Valid @RequestBody QmsPdiComponentUpdateQO request) {
|
||||
componentControllerService.update(request);
|
||||
return ApiResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除部件
|
||||
*/
|
||||
@PostMapping("/delete")
|
||||
public ApiResult<Void> delete(@NotNull(message = "ID不能为空") @RequestParam Long id) {
|
||||
componentControllerService.delete(id);
|
||||
return ApiResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询部件
|
||||
*/
|
||||
@GetMapping("/search")
|
||||
public ApiResult<IPage<QmsPdiComponentAnagement>> search(@Valid QmsPdiComponentSearchQO request) {
|
||||
return ApiResult.success(componentControllerService.search(request));
|
||||
}
|
||||
}
|
||||
|
|
@ -3,10 +3,11 @@ 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.QmsPdiDetectionRulesCopyQO;
|
||||
import com.nflg.wms.common.pojo.qo.QmsPdiDetectionRulesSearchQO;
|
||||
import com.nflg.wms.common.pojo.qo.QmsPdiDetectionRulesUpdateQO;
|
||||
import com.nflg.qms.admin.pojo.vo.QmsPdiDetectionRulesDetailVO;
|
||||
import com.nflg.wms.common.pojo.vo.QmsPdiDetectionRulesVO;
|
||||
import com.nflg.wms.common.util.EecExcelUtil;
|
||||
import com.nflg.wms.starter.BaseController;
|
||||
|
|
@ -56,6 +57,17 @@ public class QmsPdiDetectionRulesController extends BaseController {
|
|||
return ApiResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 复制PDI检测规则(含动静态检测项、发货前检查项、部件列表)
|
||||
* 校验新机型编号+销售订单号+检测类型在库中不存在,才允许复制
|
||||
*/
|
||||
@Transactional
|
||||
@PostMapping("copy")
|
||||
public ApiResult<Void> copy(@Valid @RequestBody QmsPdiDetectionRulesCopyQO request) {
|
||||
pdiDetectionRulesControllerService.copy(request);
|
||||
return ApiResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除PDI检测规则
|
||||
* 已发布不可删除;未发布且已启用也不可删除
|
||||
|
|
@ -69,6 +81,22 @@ public class QmsPdiDetectionRulesController extends BaseController {
|
|||
return ApiResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 启用/禁用PDI检测规则
|
||||
* 启用时校验同机型+销售订单号+检测类型+版本号是否已有启用记录,有则拒绝
|
||||
* 禁用时同步将发布状态改为未发布
|
||||
*
|
||||
* @param id 规则ID(必传)
|
||||
* @param enable true=启用,false=禁用
|
||||
*/
|
||||
@Transactional
|
||||
@PostMapping("updateEnable")
|
||||
public ApiResult<Void> updateEnable(@NotNull(message = "ID不能为空") @RequestParam Long id,
|
||||
@NotNull(message = "启用状态不能为空") @RequestParam Boolean enable) {
|
||||
pdiDetectionRulesControllerService.updateEnable(id, enable);
|
||||
return ApiResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量发布PDI检测规则
|
||||
* 禁用或未维护的规则不允许发布
|
||||
|
|
@ -91,18 +119,6 @@ public class QmsPdiDetectionRulesController extends BaseController {
|
|||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载机型导入模板
|
||||
*/
|
||||
|
|
@ -134,4 +150,15 @@ public class QmsPdiDetectionRulesController extends BaseController {
|
|||
@RequestBody(required = false) List<Long> ids) throws IOException {
|
||||
pdiDetectionRulesControllerService.export(response, ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询PDI检测规则详情(含动静态检测项、发货前检查项、部件列表)
|
||||
*
|
||||
* @param id 规则ID(必传)
|
||||
*/
|
||||
@GetMapping("detail")
|
||||
public ApiResult<QmsPdiDetectionRulesDetailVO> detail(
|
||||
@NotNull(message = "ID不能为空") @RequestParam Long id) {
|
||||
return ApiResult.success(pdiDetectionRulesControllerService.detail(id));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,36 @@
|
|||
package com.nflg.qms.admin.pojo.vo;
|
||||
|
||||
import com.nflg.wms.repository.entity.QmsPdiComponentAnagement;
|
||||
import com.nflg.wms.repository.entity.QmsPdiDetectionRules;
|
||||
import com.nflg.wms.repository.entity.QmsPdiDetectionRulesDeliveryItem;
|
||||
import com.nflg.wms.repository.entity.QmsPdiDetectionRulesStatusItem;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* PDI检测规则详情 VO(含4张关联表数据)
|
||||
*/
|
||||
@Data
|
||||
public class QmsPdiDetectionRulesDetailVO {
|
||||
|
||||
/**
|
||||
* 检测规则主表数据
|
||||
*/
|
||||
private QmsPdiDetectionRules rules;
|
||||
|
||||
/**
|
||||
* 动静态检测项列表(qms_pdi_detection_rules_status_item)
|
||||
*/
|
||||
private List<QmsPdiDetectionRulesStatusItem> statusItems;
|
||||
|
||||
/**
|
||||
* 发货前检查项列表(qms_pdi_detection_rules_delivery_item)
|
||||
*/
|
||||
private List<QmsPdiDetectionRulesDeliveryItem> deliveryItems;
|
||||
|
||||
/**
|
||||
* 部件列表(qms_pdi_component_anagement)
|
||||
*/
|
||||
private List<QmsPdiComponentAnagement> components;
|
||||
}
|
||||
|
|
@ -0,0 +1,93 @@
|
|||
package com.nflg.qms.admin.service;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
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.qo.QmsPdiComponentAddQO;
|
||||
import com.nflg.wms.common.pojo.qo.QmsPdiComponentSearchQO;
|
||||
import com.nflg.wms.common.pojo.qo.QmsPdiComponentUpdateQO;
|
||||
import com.nflg.wms.common.util.UserUtil;
|
||||
import com.nflg.wms.repository.entity.QmsPdiComponentAnagement;
|
||||
import com.nflg.wms.repository.mapper.QmsPdiComponentAnagementMapper;
|
||||
import com.nflg.wms.repository.service.IQmsPdiComponentAnagementService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 部件管理 ControllerService
|
||||
*/
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class QmsPdiComponentControllerService {
|
||||
|
||||
private final IQmsPdiComponentAnagementService componentService;
|
||||
private final QmsPdiComponentAnagementMapper componentMapper;
|
||||
|
||||
// ========================= 新增 =========================
|
||||
|
||||
/**
|
||||
* 新增部件
|
||||
*/
|
||||
@Transactional
|
||||
public void add(QmsPdiComponentAddQO request) {
|
||||
QmsPdiComponentAnagement entity = new QmsPdiComponentAnagement()
|
||||
.setComponentName(request.getComponentName())
|
||||
.setDeliveryRulesId(request.getDeliveryRulesId())
|
||||
.setDetectionRulesId(request.getDetectionRulesId())
|
||||
.setCreateBy(UserUtil.getUserName())
|
||||
.setCreaeteTime(LocalDateTime.now());
|
||||
componentService.save(entity);
|
||||
}
|
||||
|
||||
// ========================= 修改 =========================
|
||||
|
||||
/**
|
||||
* 修改部件(仅更新非空字段)
|
||||
*/
|
||||
@Transactional
|
||||
public void update(QmsPdiComponentUpdateQO request) {
|
||||
QmsPdiComponentAnagement existing = componentService.getById(request.getId());
|
||||
if (Objects.isNull(existing)) {
|
||||
throw new NflgException(STATE.BusinessError, "部件不存在");
|
||||
}
|
||||
var updateChain = componentService.lambdaUpdate()
|
||||
.eq(QmsPdiComponentAnagement::getId, request.getId());
|
||||
if (StrUtil.isNotBlank(request.getComponentName())) {
|
||||
updateChain.set(QmsPdiComponentAnagement::getComponentName, request.getComponentName());
|
||||
}
|
||||
if (Objects.nonNull(request.getDeliveryRulesId())) {
|
||||
updateChain.set(QmsPdiComponentAnagement::getDeliveryRulesId, request.getDeliveryRulesId());
|
||||
}
|
||||
updateChain.update();
|
||||
}
|
||||
|
||||
// ========================= 删除 =========================
|
||||
|
||||
/**
|
||||
* 删除部件
|
||||
*/
|
||||
@Transactional
|
||||
public void delete(Long id) {
|
||||
QmsPdiComponentAnagement existing = componentService.getById(id);
|
||||
if (Objects.isNull(existing)) {
|
||||
throw new NflgException(STATE.BusinessError, "部件不存在");
|
||||
}
|
||||
componentService.removeById(id);
|
||||
}
|
||||
|
||||
// ========================= 分页查询 =========================
|
||||
|
||||
/**
|
||||
* 分页查询部件
|
||||
*/
|
||||
public IPage<QmsPdiComponentAnagement> search(QmsPdiComponentSearchQO request) {
|
||||
Page<QmsPdiComponentAnagement> page = new Page<>(request.getPage(), request.getPageSize());
|
||||
return componentMapper.search(request, page);
|
||||
}
|
||||
}
|
||||
|
|
@ -10,8 +10,10 @@ import com.nflg.wms.common.pojo.qo.QmsPdiDeliveryItemUpdateQO;
|
|||
import com.nflg.wms.common.util.EecExcelUtil;
|
||||
import com.nflg.wms.common.util.UserUtil;
|
||||
import com.nflg.wms.repository.entity.QmsPdiDetectionRulesDeliveryItem;
|
||||
import com.nflg.wms.repository.entity.QmsPdiDetectionRules;
|
||||
import com.nflg.wms.repository.mapper.QmsPdiDetectionRulesDeliveryItemMapper;
|
||||
import com.nflg.wms.repository.service.IQmsPdiDetectionRulesDeliveryItemService;
|
||||
import com.nflg.wms.repository.service.IQmsPdiDetectionRulesService;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
|
@ -25,7 +27,7 @@ import java.util.Objects;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* PDI发货前检查 ControllerService
|
||||
* PDI发货前检查
|
||||
*/
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
|
|
@ -33,6 +35,7 @@ public class QmsPdiDeliveryItemControllerService {
|
|||
|
||||
private final IQmsPdiDetectionRulesDeliveryItemService deliveryItemService;
|
||||
private final QmsPdiDetectionRulesDeliveryItemMapper deliveryItemMapper;
|
||||
private final IQmsPdiDetectionRulesService pdiDetectionRulesService;
|
||||
|
||||
// ========================= 新增 =========================
|
||||
|
||||
|
|
@ -49,6 +52,7 @@ public class QmsPdiDeliveryItemControllerService {
|
|||
.setCreateBy(operator)
|
||||
.setCreateTime(now);
|
||||
deliveryItemService.save(entity);
|
||||
markMaintained(request.getDetectionRulesId());
|
||||
}
|
||||
|
||||
// ========================= 修改 =========================
|
||||
|
|
@ -120,6 +124,7 @@ public class QmsPdiDeliveryItemControllerService {
|
|||
throw new NflgException(STATE.BusinessError, "导入数据中检查项均为空,请检查文件");
|
||||
}
|
||||
deliveryItemService.saveBatch(entities);
|
||||
markMaintained(detectionRulesId);
|
||||
}
|
||||
|
||||
// ========================= 查询 =========================
|
||||
|
|
@ -135,4 +140,17 @@ public class QmsPdiDeliveryItemControllerService {
|
|||
.orderByAsc(QmsPdiDetectionRulesDeliveryItem::getId)
|
||||
.list();
|
||||
}
|
||||
|
||||
/**
|
||||
* 若主表维护状态为未维护,则更新为已维护
|
||||
*/
|
||||
private void markMaintained(Long detectionRulesId) {
|
||||
QmsPdiDetectionRules rule = pdiDetectionRulesService.getById(detectionRulesId);
|
||||
if (rule != null && !Boolean.TRUE.equals(rule.getMaintenanceEnable())) {
|
||||
pdiDetectionRulesService.lambdaUpdate()
|
||||
.eq(QmsPdiDetectionRules::getId, detectionRulesId)
|
||||
.set(QmsPdiDetectionRules::getMaintenanceEnable, true)
|
||||
.update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,15 +7,22 @@ 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.QmsPdiDetectionRulesCopyQO;
|
||||
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.qms.admin.pojo.vo.QmsPdiDetectionRulesDetailVO;
|
||||
import com.nflg.wms.common.util.EecExcelUtil;
|
||||
import com.nflg.wms.common.util.UserUtil;
|
||||
import com.nflg.wms.repository.entity.QmsPdiComponentAnagement;
|
||||
import com.nflg.wms.repository.entity.QmsPdiDetectionRules;
|
||||
import com.nflg.wms.repository.entity.QmsPdiDetectionRulesDeliveryItem;
|
||||
import com.nflg.wms.repository.entity.QmsPdiDetectionRulesStatusItem;
|
||||
import com.nflg.wms.repository.service.IQmsPdiComponentAnagementService;
|
||||
import com.nflg.wms.repository.service.IQmsPdiDetectionRulesDeliveryItemService;
|
||||
import com.nflg.wms.repository.service.IQmsPdiDetectionRulesStatusItemService;
|
||||
import com.nflg.wms.repository.mapper.QmsPdiDetectionRulesMapper;
|
||||
import com.nflg.wms.repository.service.IQmsPdiDetectionRulesService;
|
||||
import jakarta.annotation.Resource;
|
||||
|
|
@ -47,6 +54,15 @@ public class QmsPdiDetectionRulesControllerService {
|
|||
@Resource
|
||||
private BasdeSerialNumberControllerService basdeSerialNumberControllerService;
|
||||
|
||||
@Resource
|
||||
private IQmsPdiDetectionRulesStatusItemService statusItemService;
|
||||
|
||||
@Resource
|
||||
private IQmsPdiDetectionRulesDeliveryItemService deliveryItemService;
|
||||
|
||||
@Resource
|
||||
private IQmsPdiComponentAnagementService componentService;
|
||||
|
||||
// ========================= 工具方法 =========================
|
||||
|
||||
/**
|
||||
|
|
@ -146,6 +162,105 @@ public class QmsPdiDetectionRulesControllerService {
|
|||
.update();
|
||||
}
|
||||
|
||||
// ========================= 复制 =========================
|
||||
|
||||
/**
|
||||
* 复制PDI检测规则(含3张子表明细)
|
||||
* 1. 校验新机型编号+销售订单号+检测类型在库中是否已存在,存在则拒绝
|
||||
* 2. 以源规则的检测周期、质检员等信息新建主表记录,使用新的机型编号/销售订单号/检测类型
|
||||
* 3. 将源ID关联的3张子表数据复制一份,关联到新ID
|
||||
*/
|
||||
@Transactional
|
||||
public void copy(QmsPdiDetectionRulesCopyQO request) {
|
||||
// 1. 唯一性校验
|
||||
boolean exists = pdiDetectionRulesService.lambdaQuery()
|
||||
.eq(QmsPdiDetectionRules::getMachineNo, request.getMachineNo())
|
||||
.eq(QmsPdiDetectionRules::getOrderNo, request.getOrderNo())
|
||||
.eq(QmsPdiDetectionRules::getInspectionType, request.getInspectionType())
|
||||
.exists();
|
||||
if (exists) {
|
||||
throw new NflgException(STATE.BusinessError, "已存在相同机型编号、销售订单号和检测类型的规则,不允许复制");
|
||||
}
|
||||
|
||||
// 2. 查源规则
|
||||
QmsPdiDetectionRules source = pdiDetectionRulesService.getById(request.getId());
|
||||
if (Objects.isNull(source)) {
|
||||
throw new NflgException(STATE.BusinessError, "源PDI检测规则不存在");
|
||||
}
|
||||
|
||||
// 3. 计算版本号并新增主表
|
||||
String version = calcVersion(request.getMachineNo(), request.getInspectionType(), request.getOrderNo(), null);
|
||||
String operator = UserUtil.getUserName();
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
|
||||
QmsPdiDetectionRules newRule = new QmsPdiDetectionRules()
|
||||
.setRuleNo(basdeSerialNumberControllerService.generateSerialNumber(33))
|
||||
.setMachineNo(request.getMachineNo())
|
||||
.setOrderNo(request.getOrderNo())
|
||||
.setInspectionType(request.getInspectionType())
|
||||
.setInspectorId(source.getInspectorId())
|
||||
.setInspectionCycle(source.getInspectionCycle())
|
||||
.setInspectionVersion(version)
|
||||
.setMaintenanceEnable(false)
|
||||
.setEnable(false)
|
||||
.setPublishEnable(false)
|
||||
.setCreateBy(operator)
|
||||
.setCreateTime(now)
|
||||
.setUpdateBy(operator)
|
||||
.setUpdateTime(now);
|
||||
pdiDetectionRulesService.save(newRule);
|
||||
Long newId = newRule.getId();
|
||||
|
||||
// 4. 复制动静态检测项
|
||||
List<QmsPdiDetectionRulesStatusItem> statusItems = statusItemService.lambdaQuery()
|
||||
.eq(QmsPdiDetectionRulesStatusItem::getDetectionRulesId, request.getId())
|
||||
.list();
|
||||
if (CollectionUtil.isNotEmpty(statusItems)) {
|
||||
List<QmsPdiDetectionRulesStatusItem> newStatusItems = statusItems.stream()
|
||||
.map(item -> new QmsPdiDetectionRulesStatusItem()
|
||||
.setDetectionRulesId(newId)
|
||||
.setComponentsDes(item.getComponentsDes())
|
||||
.setInspectionContent(item.getInspectionContent())
|
||||
.setInspectionImage(item.getInspectionImage())
|
||||
.setStatus(item.getStatus())
|
||||
.setSetBy(operator)
|
||||
.setSetTime(now))
|
||||
.collect(java.util.stream.Collectors.toList());
|
||||
statusItemService.saveBatch(newStatusItems);
|
||||
}
|
||||
|
||||
// 5. 复制发货前检查项
|
||||
List<QmsPdiDetectionRulesDeliveryItem> deliveryItems = deliveryItemService.lambdaQuery()
|
||||
.eq(QmsPdiDetectionRulesDeliveryItem::getDetectionRulesId, request.getId())
|
||||
.list();
|
||||
if (CollectionUtil.isNotEmpty(deliveryItems)) {
|
||||
List<QmsPdiDetectionRulesDeliveryItem> newDeliveryItems = deliveryItems.stream()
|
||||
.map(item -> new QmsPdiDetectionRulesDeliveryItem()
|
||||
.setDetectionRulesId(newId)
|
||||
.setChecklist(item.getChecklist())
|
||||
.setCreateBy(operator)
|
||||
.setCreateTime(now))
|
||||
.collect(java.util.stream.Collectors.toList());
|
||||
deliveryItemService.saveBatch(newDeliveryItems);
|
||||
}
|
||||
|
||||
// 6. 复制部件
|
||||
List<QmsPdiComponentAnagement> components = componentService.lambdaQuery()
|
||||
.eq(QmsPdiComponentAnagement::getDetectionRulesId, request.getId())
|
||||
.list();
|
||||
if (CollectionUtil.isNotEmpty(components)) {
|
||||
List<QmsPdiComponentAnagement> newComponents = components.stream()
|
||||
.map(item -> new QmsPdiComponentAnagement()
|
||||
.setDetectionRulesId(newId)
|
||||
.setDeliveryRulesId(item.getDeliveryRulesId())
|
||||
.setComponentName(item.getComponentName())
|
||||
.setCreateBy(operator)
|
||||
.setCreaeteTime(now))
|
||||
.collect(java.util.stream.Collectors.toList());
|
||||
componentService.saveBatch(newComponents);
|
||||
}
|
||||
}
|
||||
|
||||
// ========================= 删除 =========================
|
||||
|
||||
/**
|
||||
|
|
@ -164,9 +279,59 @@ public class QmsPdiDetectionRulesControllerService {
|
|||
if (Boolean.TRUE.equals(existing.getEnable())) {
|
||||
throw new NflgException(STATE.BusinessError, "未发布且已启用的规则不允许删除,请先禁用后再删除");
|
||||
}
|
||||
// 级联删除动静态检测项
|
||||
statusItemService.lambdaUpdate()
|
||||
.eq(QmsPdiDetectionRulesStatusItem::getDetectionRulesId, id)
|
||||
.remove();
|
||||
// 级联删除发货前检查项
|
||||
deliveryItemService.lambdaUpdate()
|
||||
.eq(QmsPdiDetectionRulesDeliveryItem::getDetectionRulesId, id)
|
||||
.remove();
|
||||
// 删除主表
|
||||
pdiDetectionRulesService.removeById(id);
|
||||
}
|
||||
|
||||
// ========================= 启用/禁用 =========================
|
||||
|
||||
/**
|
||||
* 启用或禁用PDI检测规则
|
||||
* 启用时:校验库中是否已存在同机型编号+销售订单号+检测类型+版本号的已启用记录,若存在则抛错
|
||||
* 禁用时:预留校验(暂无),同时将发布状态改为未发布
|
||||
*/
|
||||
@Transactional
|
||||
public void updateEnable(Long id, Boolean enable) {
|
||||
QmsPdiDetectionRules existing = pdiDetectionRulesService.getById(id);
|
||||
if (Objects.isNull(existing)) {
|
||||
throw new NflgException(STATE.BusinessError, "PDI检测规则不存在");
|
||||
}
|
||||
if (Boolean.TRUE.equals(enable)) {
|
||||
// 启用:校验同机型编号+销售订单号+检测类型+版本号是否已存在启用记录
|
||||
boolean duplicate = pdiDetectionRulesService.lambdaQuery()
|
||||
.eq(QmsPdiDetectionRules::getMachineNo, existing.getMachineNo())
|
||||
.eq(QmsPdiDetectionRules::getOrderNo, existing.getOrderNo())
|
||||
.eq(QmsPdiDetectionRules::getInspectionType, existing.getInspectionType())
|
||||
.eq(QmsPdiDetectionRules::getInspectionVersion, existing.getInspectionVersion())
|
||||
.eq(QmsPdiDetectionRules::getEnable, true)
|
||||
.ne(QmsPdiDetectionRules::getId, id)
|
||||
.exists();
|
||||
if (duplicate) {
|
||||
throw new NflgException(STATE.BusinessError,
|
||||
"已存在相同机型编号、销售订单号、检测类型和版本号的已启用规则,无法重复启用");
|
||||
}
|
||||
pdiDetectionRulesService.lambdaUpdate()
|
||||
.eq(QmsPdiDetectionRules::getId, id)
|
||||
.set(QmsPdiDetectionRules::getEnable, true)
|
||||
.update();
|
||||
} else {
|
||||
// 禁用:预留校验(暂无),同时将发布状态改为未发布
|
||||
pdiDetectionRulesService.lambdaUpdate()
|
||||
.eq(QmsPdiDetectionRules::getId, id)
|
||||
.set(QmsPdiDetectionRules::getEnable, false)
|
||||
.set(QmsPdiDetectionRules::getPublishEnable, false)
|
||||
.update();
|
||||
}
|
||||
}
|
||||
|
||||
// ========================= 发布 =========================
|
||||
|
||||
/**
|
||||
|
|
@ -241,17 +406,6 @@ public class QmsPdiDetectionRulesControllerService {
|
|||
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);
|
||||
}
|
||||
|
||||
// ========================= 导入机型 =========================
|
||||
|
||||
/**
|
||||
|
|
@ -304,4 +458,34 @@ public class QmsPdiDetectionRulesControllerService {
|
|||
(ids != null && !ids.isEmpty()) ? ids : null);
|
||||
EecExcelUtil.export("PDI检测规则导出", "检测规则列表", data, response);
|
||||
}
|
||||
|
||||
// ========================= 详情 =========================
|
||||
|
||||
/**
|
||||
* 查询PDI检测规则详情(含4张关联表数据)
|
||||
*/
|
||||
public QmsPdiDetectionRulesDetailVO detail(Long id) {
|
||||
QmsPdiDetectionRules rules = pdiDetectionRulesService.getById(id);
|
||||
if (Objects.isNull(rules)) {
|
||||
throw new NflgException(STATE.BusinessError, "PDI检测规则不存在");
|
||||
}
|
||||
List<QmsPdiDetectionRulesStatusItem> statusItems = statusItemService.lambdaQuery()
|
||||
.eq(QmsPdiDetectionRulesStatusItem::getDetectionRulesId, id)
|
||||
.orderByAsc(QmsPdiDetectionRulesStatusItem::getId)
|
||||
.list();
|
||||
List<QmsPdiDetectionRulesDeliveryItem> deliveryItems = deliveryItemService.lambdaQuery()
|
||||
.eq(QmsPdiDetectionRulesDeliveryItem::getDetectionRulesId, id)
|
||||
.orderByAsc(QmsPdiDetectionRulesDeliveryItem::getId)
|
||||
.list();
|
||||
List<QmsPdiComponentAnagement> components = componentService.lambdaQuery()
|
||||
.eq(QmsPdiComponentAnagement::getDetectionRulesId, id)
|
||||
.orderByAsc(QmsPdiComponentAnagement::getId)
|
||||
.list();
|
||||
QmsPdiDetectionRulesDetailVO vo = new QmsPdiDetectionRulesDetailVO();
|
||||
vo.setRules(rules);
|
||||
vo.setStatusItems(statusItems);
|
||||
vo.setDeliveryItems(deliveryItems);
|
||||
vo.setComponents(components);
|
||||
return vo;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,8 +12,10 @@ 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.entity.QmsPdiDetectionRules;
|
||||
import com.nflg.wms.repository.mapper.QmsPdiDetectionRulesStatusItemMapper;
|
||||
import com.nflg.wms.repository.service.IQmsPdiDetectionRulesStatusItemService;
|
||||
import com.nflg.wms.repository.service.IQmsPdiDetectionRulesService;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
|
@ -27,7 +29,7 @@ import java.util.Objects;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* PDI动静态检测项 ControllerService
|
||||
* PDI动静态检测项
|
||||
*/
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
|
|
@ -35,6 +37,7 @@ public class QmsPdiStatusItemControllerService {
|
|||
|
||||
private final IQmsPdiDetectionRulesStatusItemService statusItemService;
|
||||
private final QmsPdiDetectionRulesStatusItemMapper statusItemMapper;
|
||||
private final IQmsPdiDetectionRulesService pdiDetectionRulesService;
|
||||
|
||||
// ========================= 新增 =========================
|
||||
|
||||
|
|
@ -54,6 +57,7 @@ public class QmsPdiStatusItemControllerService {
|
|||
.setSetBy(operator)
|
||||
.setSetTime(now);
|
||||
statusItemService.save(entity);
|
||||
markMaintained(request.getDetectionRulesId());
|
||||
}
|
||||
|
||||
// ========================= 修改 =========================
|
||||
|
|
@ -151,6 +155,7 @@ public class QmsPdiStatusItemControllerService {
|
|||
throw new NflgException(STATE.BusinessError, "导入数据中必填字段(部件描述、检查核实内容)均为空,请检查文件");
|
||||
}
|
||||
statusItemService.saveBatch(entities);
|
||||
markMaintained(detectionRulesId);
|
||||
}
|
||||
|
||||
// ========================= 分页查询 =========================
|
||||
|
|
@ -194,4 +199,17 @@ public class QmsPdiStatusItemControllerService {
|
|||
vo.setSetTime(item.getSetTime());
|
||||
return vo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 若主表维护状态为未维护,则更新为已维护
|
||||
*/
|
||||
private void markMaintained(Long detectionRulesId) {
|
||||
QmsPdiDetectionRules rule = pdiDetectionRulesService.getById(detectionRulesId);
|
||||
if (rule != null && !Boolean.TRUE.equals(rule.getMaintenanceEnable())) {
|
||||
pdiDetectionRulesService.lambdaUpdate()
|
||||
.eq(QmsPdiDetectionRules::getId, detectionRulesId)
|
||||
.set(QmsPdiDetectionRules::getMaintenanceEnable, true)
|
||||
.update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,30 @@
|
|||
package com.nflg.wms.common.pojo.qo;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 部件管理 新增请求参数
|
||||
*/
|
||||
@Data
|
||||
public class QmsPdiComponentAddQO {
|
||||
|
||||
/**
|
||||
* 部件名称(必传)
|
||||
*/
|
||||
@NotBlank(message = "部件名称不能为空")
|
||||
private String componentName;
|
||||
|
||||
/**
|
||||
* 动静态检测项ID(必传)
|
||||
*/
|
||||
@NotNull(message = "动静态检测项ID不能为空")
|
||||
private Long deliveryRulesId;
|
||||
|
||||
/**
|
||||
* PDI检测规则ID(必传)
|
||||
*/
|
||||
@NotNull(message = "PDI检测规则ID不能为空")
|
||||
private Long detectionRulesId;
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
package com.nflg.wms.common.pojo.qo;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 部件管理 分页查询请求参数
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class QmsPdiComponentSearchQO extends PageQO {
|
||||
|
||||
/**
|
||||
* PDI检测规则ID(必传)
|
||||
*/
|
||||
@NotNull(message = "PDI检测规则ID不能为空")
|
||||
private Long detectionRulesId;
|
||||
|
||||
/**
|
||||
* 部件名称(可选,模糊查询)
|
||||
*/
|
||||
private String componentName;
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
package com.nflg.wms.common.pojo.qo;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 部件管理 修改请求参数
|
||||
*/
|
||||
@Data
|
||||
public class QmsPdiComponentUpdateQO {
|
||||
|
||||
/**
|
||||
* ID(必传)
|
||||
*/
|
||||
@NotNull(message = "ID不能为空")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 部件名称(可选)
|
||||
*/
|
||||
private String componentName;
|
||||
|
||||
/**
|
||||
* 动静态检测项ID(可选)
|
||||
*/
|
||||
private Long deliveryRulesId;
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
package com.nflg.wms.common.pojo.qo;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* PDI检测规则 复制请求参数
|
||||
*/
|
||||
@Data
|
||||
public class QmsPdiDetectionRulesCopyQO {
|
||||
|
||||
/**
|
||||
* 源规则ID(必传)
|
||||
*/
|
||||
@NotNull(message = "源规则ID不能为空")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 新机型编号(必传)
|
||||
*/
|
||||
@NotBlank(message = "机型编号不能为空")
|
||||
private String machineNo;
|
||||
|
||||
/**
|
||||
* 新销售订单号(必传)
|
||||
*/
|
||||
@NotBlank(message = "销售订单号不能为空")
|
||||
private String orderNo;
|
||||
|
||||
/**
|
||||
* 新检测类型(必传)
|
||||
*/
|
||||
@NotNull(message = "检测类型不能为空")
|
||||
private Integer inspectionType;
|
||||
}
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
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;
|
||||
|
||||
/**
|
||||
* 部件管理
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@Accessors(chain = true)
|
||||
@TableName("qms_pdi_component_anagement")
|
||||
public class QmsPdiComponentAnagement implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "id", type = IdType.ASSIGN_ID)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 部件名称
|
||||
*/
|
||||
private String componentName;
|
||||
|
||||
/**
|
||||
* 动静态检测项ID
|
||||
*/
|
||||
private Long deliveryRulesId;
|
||||
|
||||
/**
|
||||
* PDI检测规则ID
|
||||
*/
|
||||
private Long detectionRulesId;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime creaeteTime;
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
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.QmsPdiComponentSearchQO;
|
||||
import com.nflg.wms.repository.entity.QmsPdiComponentAnagement;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 部件管理 Mapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface QmsPdiComponentAnagementMapper extends BaseMapper<QmsPdiComponentAnagement> {
|
||||
|
||||
IPage<QmsPdiComponentAnagement> search(QmsPdiComponentSearchQO request, Page<?> page);
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
package com.nflg.wms.repository.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.nflg.wms.repository.entity.QmsPdiComponentAnagement;
|
||||
|
||||
/**
|
||||
* 部件管理 Service
|
||||
*/
|
||||
public interface IQmsPdiComponentAnagementService extends IService<QmsPdiComponentAnagement> {
|
||||
}
|
||||
|
|
@ -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.QmsPdiComponentAnagement;
|
||||
import com.nflg.wms.repository.mapper.QmsPdiComponentAnagementMapper;
|
||||
import com.nflg.wms.repository.service.IQmsPdiComponentAnagementService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 部件管理 ServiceImpl
|
||||
*/
|
||||
@Service
|
||||
public class QmsPdiComponentAnagementServiceImpl
|
||||
extends ServiceImpl<QmsPdiComponentAnagementMapper, QmsPdiComponentAnagement>
|
||||
implements IQmsPdiComponentAnagementService {
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
<?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.QmsPdiComponentAnagementMapper">
|
||||
|
||||
<!-- 分页查询部件 -->
|
||||
<select id="search" resultType="com.nflg.wms.repository.entity.QmsPdiComponentAnagement">
|
||||
SELECT
|
||||
c.id,
|
||||
c.component_name,
|
||||
c.delivery_rules_id,
|
||||
c.detection_rules_id,
|
||||
c.create_by,
|
||||
c.creaete_time
|
||||
FROM qms_pdi_component_anagement c
|
||||
WHERE c.detection_rules_id = #{request.detectionRulesId}
|
||||
<if test="request.componentName != null and request.componentName != ''">
|
||||
AND c.component_name LIKE CONCAT('%', #{request.componentName}, '%')
|
||||
</if>
|
||||
ORDER BY c.id ASC
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue