Merge remote-tracking branch '惠信/qms/develop' into qms/develop
This commit is contained in:
commit
9317c2f9b5
|
|
@ -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<Void> add(@Valid @RequestBody QmsPdiDeliveryItemAddQO request) {
|
||||
deliveryItemControllerService.add(request);
|
||||
return ApiResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改检查项
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
public ApiResult<Void> update(@Valid @RequestBody QmsPdiDeliveryItemUpdateQO request) {
|
||||
deliveryItemControllerService.update(request);
|
||||
return ApiResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除检查项
|
||||
*/
|
||||
@PostMapping("/delete")
|
||||
public ApiResult<Void> 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<Long> 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<Void> 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<List<QmsPdiDetectionRulesDeliveryItem>> search(
|
||||
@NotNull(message = "PDI检测规则ID不能为空") @RequestParam Long detectionRulesId) {
|
||||
return ApiResult.success(deliveryItemControllerService.search(detectionRulesId));
|
||||
}
|
||||
}
|
||||
|
|
@ -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<Long> ids, Long detectionRulesId) throws IOException {
|
||||
List<QmsPdiDeliveryItemExportDTO> data = deliveryItemMapper.listForExport(ids, detectionRulesId);
|
||||
EecExcelUtil.export("PDI发货前检查项", "PDI发货前检查项", data, response);
|
||||
}
|
||||
|
||||
// ========================= 导入 =========================
|
||||
|
||||
/**
|
||||
* 导入PDI发货前检查项
|
||||
*/
|
||||
@Transactional
|
||||
public void importFromExcel(MultipartFile file, Long detectionRulesId) throws IOException {
|
||||
List<QmsPdiDeliveryItemExportDTO> 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<QmsPdiDetectionRulesDeliveryItem> 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<QmsPdiDetectionRulesDeliveryItem> search(Long detectionRulesId) {
|
||||
return deliveryItemService.lambdaQuery()
|
||||
.eq(QmsPdiDetectionRulesDeliveryItem::getDetectionRulesId, detectionRulesId)
|
||||
.orderByAsc(QmsPdiDetectionRulesDeliveryItem::getId)
|
||||
.list();
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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),必传
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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<QmsPdiDetectionRulesDeliveryItem> {
|
||||
|
||||
/**
|
||||
* 导出发货前检查项
|
||||
*
|
||||
* @param ids 可选,指定ID列表;为空则按 detectionRulesId 全量导出
|
||||
* @param detectionRulesId PDI检测规则ID
|
||||
*/
|
||||
List<QmsPdiDeliveryItemExportDTO> listForExport(@Param("ids") List<Long> ids,
|
||||
@Param("detectionRulesId") Long detectionRulesId);
|
||||
}
|
||||
|
|
@ -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<QmsPdiDetectionRulesDeliveryItem> {
|
||||
}
|
||||
|
|
@ -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<QmsPdiDetectionRulesDeliveryItemMapper, QmsPdiDetectionRulesDeliveryItem>
|
||||
implements IQmsPdiDetectionRulesDeliveryItemService {
|
||||
}
|
||||
|
|
@ -464,7 +464,7 @@ public class QmsQualityInspectorServiceImpl extends ServiceImpl<QmsQualityInspec
|
|||
@Override
|
||||
public void transfer(QmsQualityInspectorTransferQO request) {
|
||||
lambdaUpdate()
|
||||
.eq(QmsQualityInspector::getUserId, request.getUserId())
|
||||
.eq(QmsQualityInspector::getId, request.getId())
|
||||
.set(QmsQualityInspector::getChangeUserId, request.getChangeUserId())
|
||||
.set(QmsQualityInspector::getUpdateBy, UserUtil.getUserName())
|
||||
.set(QmsQualityInspector::getUpdateTime, LocalDateTime.now())
|
||||
|
|
|
|||
|
|
@ -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.QmsPdiDetectionRulesDeliveryItemMapper">
|
||||
|
||||
<!-- 导出发货前检查项 -->
|
||||
<select id="listForExport" resultType="com.nflg.wms.common.pojo.dto.QmsPdiDeliveryItemExportDTO">
|
||||
SELECT
|
||||
d.checklist,
|
||||
d.create_by,
|
||||
d.create_time
|
||||
FROM qms_pdi_detection_rules_delivery_item d
|
||||
WHERE d.detection_rules_id = #{detectionRulesId}
|
||||
<if test="ids != null and ids.size() > 0">
|
||||
AND d.id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
ORDER BY d.id ASC
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue