From fc4bad964868f5c76aebc497c6526b6355ef9bfc Mon Sep 17 00:00:00 2001 From: funny <834502597@qq.com> Date: Wed, 22 Apr 2026 14:03:05 +0800 Subject: [PATCH] =?UTF-8?q?pdi=E6=A3=80=E6=B5=8B=E5=8A=9F=E8=83=BD=20?= =?UTF-8?q?=E8=B4=A8=E6=A3=80=E4=BA=BA=E5=91=98=E7=AE=A1=E7=90=86=E8=BD=AC?= =?UTF-8?q?=E5=8A=9E=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../QmsPdiDeliveryItemController.java | 97 ++++++++++++ .../QmsPdiDeliveryItemControllerService.java | 138 ++++++++++++++++++ .../pojo/dto/QmsPdiDeliveryItemExportDTO.java | 24 +++ .../pojo/qo/QmsPdiDeliveryItemAddQO.java | 24 +++ .../pojo/qo/QmsPdiDeliveryItemUpdateQO.java | 22 +++ .../qo/QmsQualityInspectorTransferQO.java | 6 +- .../QmsPdiDetectionRulesDeliveryItem.java | 48 ++++++ ...msPdiDetectionRulesDeliveryItemMapper.java | 25 ++++ ...sPdiDetectionRulesDeliveryItemService.java | 10 ++ ...DetectionRulesDeliveryItemServiceImpl.java | 16 ++ .../impl/QmsQualityInspectorServiceImpl.java | 2 +- ...QmsPdiDetectionRulesDeliveryItemMapper.xml | 22 +++ 12 files changed, 430 insertions(+), 4 deletions(-) create mode 100644 nflg-qms-admin/src/main/java/com/nflg/qms/admin/controller/QmsPdiDeliveryItemController.java create mode 100644 nflg-qms-admin/src/main/java/com/nflg/qms/admin/service/QmsPdiDeliveryItemControllerService.java create mode 100644 nflg-wms-common/src/main/java/com/nflg/wms/common/pojo/dto/QmsPdiDeliveryItemExportDTO.java create mode 100644 nflg-wms-common/src/main/java/com/nflg/wms/common/pojo/qo/QmsPdiDeliveryItemAddQO.java create mode 100644 nflg-wms-common/src/main/java/com/nflg/wms/common/pojo/qo/QmsPdiDeliveryItemUpdateQO.java create mode 100644 nflg-wms-repository/src/main/java/com/nflg/wms/repository/entity/QmsPdiDetectionRulesDeliveryItem.java create mode 100644 nflg-wms-repository/src/main/java/com/nflg/wms/repository/mapper/QmsPdiDetectionRulesDeliveryItemMapper.java create mode 100644 nflg-wms-repository/src/main/java/com/nflg/wms/repository/service/IQmsPdiDetectionRulesDeliveryItemService.java create mode 100644 nflg-wms-repository/src/main/java/com/nflg/wms/repository/service/impl/QmsPdiDetectionRulesDeliveryItemServiceImpl.java create mode 100644 nflg-wms-repository/src/main/resources/mapper/QmsPdiDetectionRulesDeliveryItemMapper.xml diff --git a/nflg-qms-admin/src/main/java/com/nflg/qms/admin/controller/QmsPdiDeliveryItemController.java b/nflg-qms-admin/src/main/java/com/nflg/qms/admin/controller/QmsPdiDeliveryItemController.java new file mode 100644 index 00000000..ec7ed04c --- /dev/null +++ b/nflg-qms-admin/src/main/java/com/nflg/qms/admin/controller/QmsPdiDeliveryItemController.java @@ -0,0 +1,97 @@ +package com.nflg.qms.admin.controller; + +import com.nflg.qms.admin.service.QmsPdiDeliveryItemControllerService; +import com.nflg.wms.common.pojo.ApiResult; +import com.nflg.wms.common.pojo.qo.QmsPdiDeliveryItemAddQO; +import com.nflg.wms.common.pojo.qo.QmsPdiDeliveryItemUpdateQO; +import com.nflg.wms.common.util.EecExcelUtil; +import com.nflg.wms.repository.entity.QmsPdiDetectionRulesDeliveryItem; +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("/pdiDeliveryItem") +public class QmsPdiDeliveryItemController extends BaseController { + + @Resource + private QmsPdiDeliveryItemControllerService deliveryItemControllerService; + + /** + * 新增检查项 + */ + @PostMapping("/add") + public ApiResult add(@Valid @RequestBody QmsPdiDeliveryItemAddQO request) { + deliveryItemControllerService.add(request); + return ApiResult.success(); + } + + /** + * 修改检查项 + */ + @PostMapping("/update") + public ApiResult update(@Valid @RequestBody QmsPdiDeliveryItemUpdateQO request) { + deliveryItemControllerService.update(request); + return ApiResult.success(); + } + + /** + * 删除检查项 + */ + @PostMapping("/delete") + public ApiResult delete(@NotNull(message = "ID不能为空") @RequestParam Long id) { + deliveryItemControllerService.delete(id); + return ApiResult.success(); + } + + /** + * 导出检查项 + * ids可选,detectionRulesId必传 + */ + @GetMapping("/export") + public void export(HttpServletResponse response, + @RequestParam(required = false) List ids, + @NotNull(message = "PDI检测规则ID不能为空") @RequestParam Long detectionRulesId) throws IOException { + deliveryItemControllerService.export(response, ids, detectionRulesId); + } + + /** + * 下载导入模板 + */ + @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) throws IOException { + deliveryItemControllerService.importFromExcel(file, detectionRulesId); + return ApiResult.success(); + } + + /** + * 查询检查项列表 + */ + @GetMapping("/search") + public ApiResult> search( + @NotNull(message = "PDI检测规则ID不能为空") @RequestParam Long detectionRulesId) { + return ApiResult.success(deliveryItemControllerService.search(detectionRulesId)); + } +} diff --git a/nflg-qms-admin/src/main/java/com/nflg/qms/admin/service/QmsPdiDeliveryItemControllerService.java b/nflg-qms-admin/src/main/java/com/nflg/qms/admin/service/QmsPdiDeliveryItemControllerService.java new file mode 100644 index 00000000..57ee2242 --- /dev/null +++ b/nflg-qms-admin/src/main/java/com/nflg/qms/admin/service/QmsPdiDeliveryItemControllerService.java @@ -0,0 +1,138 @@ +package com.nflg.qms.admin.service; + +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.StrUtil; +import com.nflg.wms.common.constant.STATE; +import com.nflg.wms.common.exception.NflgException; +import com.nflg.wms.common.pojo.dto.QmsPdiDeliveryItemExportDTO; +import com.nflg.wms.common.pojo.qo.QmsPdiDeliveryItemAddQO; +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.mapper.QmsPdiDetectionRulesDeliveryItemMapper; +import com.nflg.wms.repository.service.IQmsPdiDetectionRulesDeliveryItemService; +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 QmsPdiDeliveryItemControllerService { + + private final IQmsPdiDetectionRulesDeliveryItemService deliveryItemService; + private final QmsPdiDetectionRulesDeliveryItemMapper deliveryItemMapper; + + // ========================= 新增 ========================= + + /** + * 新增PDI发货前检查项 + */ + @Transactional + public void add(QmsPdiDeliveryItemAddQO request) { + String operator = UserUtil.getUserName(); + LocalDateTime now = LocalDateTime.now(); + QmsPdiDetectionRulesDeliveryItem entity = new QmsPdiDetectionRulesDeliveryItem() + .setDetectionRulesId(request.getDetectionRulesId()) + .setChecklist(request.getChecklist()) + .setCreateBy(operator) + .setCreateTime(now); + deliveryItemService.save(entity); + } + + // ========================= 修改 ========================= + + /** + * 修改PDI发货前检查项(仅更新非空字段) + */ + @Transactional + public void update(QmsPdiDeliveryItemUpdateQO request) { + QmsPdiDetectionRulesDeliveryItem existing = deliveryItemService.getById(request.getId()); + if (Objects.isNull(existing)) { + throw new NflgException(STATE.BusinessError, "检查项不存在"); + } + var updateChain = deliveryItemService.lambdaUpdate() + .eq(QmsPdiDetectionRulesDeliveryItem::getId, request.getId()); + if (StrUtil.isNotBlank(request.getChecklist())) { + updateChain.set(QmsPdiDetectionRulesDeliveryItem::getChecklist, request.getChecklist()); + } + updateChain.update(); + } + + // ========================= 删除 ========================= + + /** + * 删除PDI发货前检查项 + */ + @Transactional + public void delete(Long id) { + QmsPdiDetectionRulesDeliveryItem existing = deliveryItemService.getById(id); + if (Objects.isNull(existing)) { + throw new NflgException(STATE.BusinessError, "检查项不存在"); + } + deliveryItemService.removeById(id); + } + + // ========================= 导出 ========================= + + /** + * 导出PDI发货前检查项 + * ids不为空则导出指定ID数据,否则全量导出 + */ + public void export(HttpServletResponse response, List ids, Long detectionRulesId) throws IOException { + List data = deliveryItemMapper.listForExport(ids, detectionRulesId); + EecExcelUtil.export("PDI发货前检查项", "PDI发货前检查项", data, response); + } + + // ========================= 导入 ========================= + + /** + * 导入PDI发货前检查项 + */ + @Transactional + public void importFromExcel(MultipartFile file, Long detectionRulesId) throws IOException { + List data = EecExcelUtil.readTo(file.getInputStream(), QmsPdiDeliveryItemExportDTO.class); + if (CollectionUtil.isEmpty(data)) { + throw new NflgException(STATE.BusinessError, "导入文件内容为空"); + } + String operator = UserUtil.getUserName(); + LocalDateTime now = LocalDateTime.now(); + List entities = data.stream() + .filter(dto -> StrUtil.isNotBlank(dto.getChecklist())) + .map(dto -> new QmsPdiDetectionRulesDeliveryItem() + .setDetectionRulesId(detectionRulesId) + .setChecklist(dto.getChecklist()) + .setCreateBy(operator) + .setCreateTime(now)) + .collect(Collectors.toList()); + if (CollectionUtil.isEmpty(entities)) { + throw new NflgException(STATE.BusinessError, "导入数据中检查项均为空,请检查文件"); + } + deliveryItemService.saveBatch(entities); + } + + // ========================= 查询 ========================= + + /** + * 查询PDI发货前检查项列表 + * + * @param detectionRulesId PDI检测规则ID(必传) + */ + public List search(Long detectionRulesId) { + return deliveryItemService.lambdaQuery() + .eq(QmsPdiDetectionRulesDeliveryItem::getDetectionRulesId, detectionRulesId) + .orderByAsc(QmsPdiDetectionRulesDeliveryItem::getId) + .list(); + } +} diff --git a/nflg-wms-common/src/main/java/com/nflg/wms/common/pojo/dto/QmsPdiDeliveryItemExportDTO.java b/nflg-wms-common/src/main/java/com/nflg/wms/common/pojo/dto/QmsPdiDeliveryItemExportDTO.java new file mode 100644 index 00000000..38a6df45 --- /dev/null +++ b/nflg-wms-common/src/main/java/com/nflg/wms/common/pojo/dto/QmsPdiDeliveryItemExportDTO.java @@ -0,0 +1,24 @@ +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 QmsPdiDeliveryItemExportDTO { + + @ExcelColumn("检查项") + private String checklist; + + @ExcelColumn("创建人") + private String createBy; + + @ExcelColumn("创建时间") + private LocalDateTime createTime; +} diff --git a/nflg-wms-common/src/main/java/com/nflg/wms/common/pojo/qo/QmsPdiDeliveryItemAddQO.java b/nflg-wms-common/src/main/java/com/nflg/wms/common/pojo/qo/QmsPdiDeliveryItemAddQO.java new file mode 100644 index 00000000..a7541cc3 --- /dev/null +++ b/nflg-wms-common/src/main/java/com/nflg/wms/common/pojo/qo/QmsPdiDeliveryItemAddQO.java @@ -0,0 +1,24 @@ +package com.nflg.wms.common.pojo.qo; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +/** + * PDI发货前检查 新增请求参数 + */ +@Data +public class QmsPdiDeliveryItemAddQO { + + /** + * PDI检测规则ID(必传) + */ + @NotNull(message = "PDI检测规则ID不能为空") + private Long detectionRulesId; + + /** + * 检查项(必传) + */ + @NotBlank(message = "检查项不能为空") + private String checklist; +} diff --git a/nflg-wms-common/src/main/java/com/nflg/wms/common/pojo/qo/QmsPdiDeliveryItemUpdateQO.java b/nflg-wms-common/src/main/java/com/nflg/wms/common/pojo/qo/QmsPdiDeliveryItemUpdateQO.java new file mode 100644 index 00000000..101349da --- /dev/null +++ b/nflg-wms-common/src/main/java/com/nflg/wms/common/pojo/qo/QmsPdiDeliveryItemUpdateQO.java @@ -0,0 +1,22 @@ +package com.nflg.wms.common.pojo.qo; + +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +/** + * PDI发货前检查 修改请求参数 + */ +@Data +public class QmsPdiDeliveryItemUpdateQO { + + /** + * ID(必传) + */ + @NotNull(message = "ID不能为空") + private Long id; + + /** + * 检查项(可选) + */ + private String checklist; +} diff --git a/nflg-wms-common/src/main/java/com/nflg/wms/common/pojo/qo/QmsQualityInspectorTransferQO.java b/nflg-wms-common/src/main/java/com/nflg/wms/common/pojo/qo/QmsQualityInspectorTransferQO.java index e0d66059..6cde3971 100644 --- a/nflg-wms-common/src/main/java/com/nflg/wms/common/pojo/qo/QmsQualityInspectorTransferQO.java +++ b/nflg-wms-common/src/main/java/com/nflg/wms/common/pojo/qo/QmsQualityInspectorTransferQO.java @@ -10,10 +10,10 @@ import lombok.Data; public class QmsQualityInspectorTransferQO { /** - * 当前员工ID,必传 + * 质检人员主表ID,必传 */ - @NotNull(message = "员工ID不能为空") - private Long userId; + @NotNull(message = "ID不能为空") + private Long id; /** * 转办人ID(user.id),必传 diff --git a/nflg-wms-repository/src/main/java/com/nflg/wms/repository/entity/QmsPdiDetectionRulesDeliveryItem.java b/nflg-wms-repository/src/main/java/com/nflg/wms/repository/entity/QmsPdiDetectionRulesDeliveryItem.java new file mode 100644 index 00000000..8be31681 --- /dev/null +++ b/nflg-wms-repository/src/main/java/com/nflg/wms/repository/entity/QmsPdiDetectionRulesDeliveryItem.java @@ -0,0 +1,48 @@ +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_delivery_item") +public class QmsPdiDetectionRulesDeliveryItem 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 checklist; + + /** + * 创建人 + */ + private String createBy; + + /** + * 创建时间 + */ + private LocalDateTime createTime; +} diff --git a/nflg-wms-repository/src/main/java/com/nflg/wms/repository/mapper/QmsPdiDetectionRulesDeliveryItemMapper.java b/nflg-wms-repository/src/main/java/com/nflg/wms/repository/mapper/QmsPdiDetectionRulesDeliveryItemMapper.java new file mode 100644 index 00000000..93167177 --- /dev/null +++ b/nflg-wms-repository/src/main/java/com/nflg/wms/repository/mapper/QmsPdiDetectionRulesDeliveryItemMapper.java @@ -0,0 +1,25 @@ +package com.nflg.wms.repository.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.nflg.wms.common.pojo.dto.QmsPdiDeliveryItemExportDTO; +import com.nflg.wms.repository.entity.QmsPdiDetectionRulesDeliveryItem; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * PDI发货前检查 Mapper + */ +@Mapper +public interface QmsPdiDetectionRulesDeliveryItemMapper extends BaseMapper { + + /** + * 导出发货前检查项 + * + * @param ids 可选,指定ID列表;为空则按 detectionRulesId 全量导出 + * @param detectionRulesId PDI检测规则ID + */ + List listForExport(@Param("ids") List ids, + @Param("detectionRulesId") Long detectionRulesId); +} diff --git a/nflg-wms-repository/src/main/java/com/nflg/wms/repository/service/IQmsPdiDetectionRulesDeliveryItemService.java b/nflg-wms-repository/src/main/java/com/nflg/wms/repository/service/IQmsPdiDetectionRulesDeliveryItemService.java new file mode 100644 index 00000000..90d952e5 --- /dev/null +++ b/nflg-wms-repository/src/main/java/com/nflg/wms/repository/service/IQmsPdiDetectionRulesDeliveryItemService.java @@ -0,0 +1,10 @@ +package com.nflg.wms.repository.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.nflg.wms.repository.entity.QmsPdiDetectionRulesDeliveryItem; + +/** + * PDI发货前检查 Service + */ +public interface IQmsPdiDetectionRulesDeliveryItemService extends IService { +} diff --git a/nflg-wms-repository/src/main/java/com/nflg/wms/repository/service/impl/QmsPdiDetectionRulesDeliveryItemServiceImpl.java b/nflg-wms-repository/src/main/java/com/nflg/wms/repository/service/impl/QmsPdiDetectionRulesDeliveryItemServiceImpl.java new file mode 100644 index 00000000..9b168f5e --- /dev/null +++ b/nflg-wms-repository/src/main/java/com/nflg/wms/repository/service/impl/QmsPdiDetectionRulesDeliveryItemServiceImpl.java @@ -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.QmsPdiDetectionRulesDeliveryItem; +import com.nflg.wms.repository.mapper.QmsPdiDetectionRulesDeliveryItemMapper; +import com.nflg.wms.repository.service.IQmsPdiDetectionRulesDeliveryItemService; +import org.springframework.stereotype.Service; + +/** + * PDI发货前检查 ServiceImpl + */ +@Service +public class QmsPdiDetectionRulesDeliveryItemServiceImpl + extends ServiceImpl + implements IQmsPdiDetectionRulesDeliveryItemService { +} diff --git a/nflg-wms-repository/src/main/java/com/nflg/wms/repository/service/impl/QmsQualityInspectorServiceImpl.java b/nflg-wms-repository/src/main/java/com/nflg/wms/repository/service/impl/QmsQualityInspectorServiceImpl.java index 318c0d95..32b45ac5 100644 --- a/nflg-wms-repository/src/main/java/com/nflg/wms/repository/service/impl/QmsQualityInspectorServiceImpl.java +++ b/nflg-wms-repository/src/main/java/com/nflg/wms/repository/service/impl/QmsQualityInspectorServiceImpl.java @@ -464,7 +464,7 @@ public class QmsQualityInspectorServiceImpl extends ServiceImpl + + + + + + +