parent
5695961008
commit
36341938b2
|
|
@ -0,0 +1,67 @@
|
|||
package com.nflg.qms.admin.controller;
|
||||
|
||||
import com.nflg.qms.admin.service.QmsPrincipalControllerService;
|
||||
import com.nflg.wms.common.pojo.ApiResult;
|
||||
import com.nflg.wms.common.pojo.PageData;
|
||||
import com.nflg.wms.common.pojo.qo.QmsPrincipalAddQO;
|
||||
import com.nflg.wms.common.pojo.qo.QmsPrincipalSearchQO;
|
||||
import com.nflg.wms.common.pojo.qo.QmsPrincipalUpdateQO;
|
||||
import com.nflg.wms.common.pojo.vo.QmsPrincipalVO;
|
||||
import com.nflg.wms.starter.BaseController;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* QMS负责人配置
|
||||
*/
|
||||
@Validated
|
||||
@RestController
|
||||
@RequestMapping("/qmsPrincipal")
|
||||
public class QmsPrincipalController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private QmsPrincipalControllerService principalControllerService;
|
||||
|
||||
/**
|
||||
* 新增负责人配置
|
||||
*/
|
||||
@PostMapping("add")
|
||||
public ApiResult<Void> add(@Valid @RequestBody QmsPrincipalAddQO request) {
|
||||
principalControllerService.add(request);
|
||||
return ApiResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除负责人配置
|
||||
*/
|
||||
@PostMapping("delete")
|
||||
public ApiResult<Void> delete(@RequestBody @NotEmpty(message = "ID不能为空") List<Long> ids) {
|
||||
principalControllerService.delete(ids);
|
||||
return ApiResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询负责人配置
|
||||
*/
|
||||
@PostMapping("search")
|
||||
public ApiResult<PageData<QmsPrincipalVO>> search(@RequestBody QmsPrincipalSearchQO request) {
|
||||
return ApiResult.success(principalControllerService.search(request));
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新负责人配置
|
||||
*/
|
||||
@PostMapping("update")
|
||||
public ApiResult<Void> update(@Valid @RequestBody QmsPrincipalUpdateQO request) {
|
||||
principalControllerService.update(request);
|
||||
return ApiResult.success();
|
||||
}
|
||||
}
|
||||
|
|
@ -1081,20 +1081,8 @@ public class QmsIssueTicketControllerService {
|
|||
.throwMessage("工单标题不能为空");
|
||||
VUtil.trueThrowBusinessError(StrUtil.isBlank(request.getProjectNo()))
|
||||
.throwMessage("工程编号不能为空");
|
||||
VUtil.trueThrowBusinessError(request.getIncidentType() == null)
|
||||
.throwMessage("事故类型不能为空");
|
||||
VUtil.trueThrowBusinessError(StrUtil.isBlank(request.getExceptionCode()))
|
||||
.throwMessage("异常代码不能为空");
|
||||
VUtil.trueThrowBusinessError(StrUtil.isBlank(request.getImpactQuantity()))
|
||||
.throwMessage("影响数量不能为空");
|
||||
VUtil.trueThrowBusinessError(StrUtil.isBlank(request.getIncidentLocation()))
|
||||
.throwMessage("事件地点不能为空");
|
||||
VUtil.trueThrowBusinessError(StrUtil.isBlank(request.getIncidentDescription()))
|
||||
.throwMessage("事件描述不能为空");
|
||||
VUtil.trueThrowBusinessError(StrUtil.isBlank(request.getIncidentReason()))
|
||||
.throwMessage("事件原因不能为空");
|
||||
VUtil.trueThrowBusinessError(StrUtil.isBlank(request.getIncidentConsequence()))
|
||||
.throwMessage("事件后果不能为空");
|
||||
|
||||
// 3. 校验图片字段完整性(如果有图片的话)
|
||||
if (CollectionUtil.isNotEmpty(request.getImages())) {
|
||||
|
|
@ -1126,13 +1114,7 @@ public class QmsIssueTicketControllerService {
|
|||
.setTicketNo(ticketNo)
|
||||
.setTicketTitle(request.getTicketTitle())
|
||||
.setProjectNo(request.getProjectNo())
|
||||
.setIncidentType(request.getIncidentType())
|
||||
.setExceptionCode(request.getExceptionCode())
|
||||
.setImpactQuantity(request.getImpactQuantity())
|
||||
.setIncidentLocation(request.getIncidentLocation())
|
||||
.setIncidentDescription(request.getIncidentDescription())
|
||||
.setIncidentReason(request.getIncidentReason())
|
||||
.setIncidentConsequence(request.getIncidentConsequence())
|
||||
.setImageIds(request.getImages() == null
|
||||
? ""
|
||||
: StrUtil.join(",", request.getImages().stream().map(FileUploadVO::getId).toList())
|
||||
|
|
|
|||
|
|
@ -0,0 +1,150 @@
|
|||
package com.nflg.qms.admin.service;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
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.qo.QmsPrincipalAddQO;
|
||||
import com.nflg.wms.common.pojo.qo.QmsPrincipalSearchQO;
|
||||
import com.nflg.wms.common.pojo.qo.QmsPrincipalUpdateQO;
|
||||
import com.nflg.wms.common.pojo.vo.QmsPrincipalVO;
|
||||
import com.nflg.wms.common.util.UserUtil;
|
||||
import com.nflg.wms.repository.entity.QmsPrincipal;
|
||||
import com.nflg.wms.repository.entity.User;
|
||||
import com.nflg.wms.repository.service.IQmsPrincipalService;
|
||||
import com.nflg.wms.repository.service.IUserService;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* QMS负责人配置业务逻辑
|
||||
*/
|
||||
@Component
|
||||
public class QmsPrincipalControllerService {
|
||||
|
||||
@Resource
|
||||
private IQmsPrincipalService principalService;
|
||||
|
||||
@Resource
|
||||
private IUserService userService;
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void add(@Valid QmsPrincipalAddQO request) {
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
Long currentUserId = UserUtil.getUserId();
|
||||
|
||||
QmsPrincipal principal = new QmsPrincipal()
|
||||
.setUserId(request.getUserId())
|
||||
.setQmsUserType(request.getQmsUserType())
|
||||
.setCreateBy(currentUserId)
|
||||
.setCreateTime(now)
|
||||
.setUpdateBy(currentUserId)
|
||||
.setUpdateTime(now);
|
||||
principalService.save(principal);
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void delete(List<Long> ids) {
|
||||
boolean removed = principalService.removeByIds(ids);
|
||||
if (!removed) {
|
||||
throw new NflgException(STATE.BusinessError, "数据不存在");
|
||||
}
|
||||
}
|
||||
|
||||
public PageData<QmsPrincipalVO> search(QmsPrincipalSearchQO request) {
|
||||
List<Long> userIds = null;
|
||||
if (StrUtil.isNotBlank(request.getUserName())) {
|
||||
userIds = userService.lambdaQuery()
|
||||
.like(User::getUserName, request.getUserName())
|
||||
.list()
|
||||
.stream()
|
||||
.map(User::getId)
|
||||
.collect(Collectors.toList());
|
||||
if (CollectionUtil.isEmpty(userIds)) {
|
||||
PageData<QmsPrincipalVO> empty = new PageData<>();
|
||||
empty.setPage(request.getPage());
|
||||
empty.setPageSize(request.getPageSize());
|
||||
return empty;
|
||||
}
|
||||
}
|
||||
|
||||
var query = principalService.lambdaQuery()
|
||||
.eq(request.getQmsUserType() != null, QmsPrincipal::getQmsUserType, request.getQmsUserType())
|
||||
.in(CollectionUtil.isNotEmpty(userIds), QmsPrincipal::getUserId, userIds)
|
||||
.orderByDesc(QmsPrincipal::getCreateTime);
|
||||
|
||||
Page<QmsPrincipal> page = query.page(new Page<>(request.getPage(), request.getPageSize()));
|
||||
|
||||
Map<Long, String> userNameMap = buildUserNameMap(page.getRecords());
|
||||
List<QmsPrincipalVO> voList = page.getRecords().stream()
|
||||
.map(entity -> {
|
||||
QmsPrincipalVO vo = BeanUtil.copyProperties(entity, QmsPrincipalVO.class);
|
||||
vo.setUserName(userNameMap.get(entity.getUserId()));
|
||||
vo.setCreateByName(userNameMap.get(entity.getCreateBy()));
|
||||
vo.setUpdateByName(userNameMap.get(entity.getUpdateBy()));
|
||||
return vo;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
PageData<QmsPrincipalVO> pageData = new PageData<>();
|
||||
pageData.setPage((int) page.getCurrent());
|
||||
pageData.setPageSize((int) page.getSize());
|
||||
pageData.setTotal((int) page.getTotal());
|
||||
pageData.setItems(voList);
|
||||
return pageData;
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(@Valid QmsPrincipalUpdateQO request) {
|
||||
QmsPrincipal principal = principalService.getById(request.getId());
|
||||
if (principal == null) {
|
||||
throw new NflgException(STATE.BusinessError, "数据不存在");
|
||||
}
|
||||
|
||||
principalService.lambdaUpdate()
|
||||
.eq(QmsPrincipal::getId, request.getId())
|
||||
.set(QmsPrincipal::getQmsUserType, request.getQmsUserType())
|
||||
.set(QmsPrincipal::getUpdateBy, UserUtil.getUserId())
|
||||
.set(QmsPrincipal::getUpdateTime, LocalDateTime.now())
|
||||
.update();
|
||||
}
|
||||
|
||||
private Map<Long, String> buildUserNameMap(List<QmsPrincipal> records) {
|
||||
if (CollectionUtil.isEmpty(records)) {
|
||||
return Map.of();
|
||||
}
|
||||
|
||||
Set<Long> userIds = new HashSet<>();
|
||||
for (QmsPrincipal record : records) {
|
||||
if (record.getUserId() != null) {
|
||||
userIds.add(record.getUserId());
|
||||
}
|
||||
if (record.getCreateBy() != null) {
|
||||
userIds.add(record.getCreateBy());
|
||||
}
|
||||
if (record.getUpdateBy() != null) {
|
||||
userIds.add(record.getUpdateBy());
|
||||
}
|
||||
}
|
||||
if (CollectionUtil.isEmpty(userIds)) {
|
||||
return Map.of();
|
||||
}
|
||||
|
||||
return userService.listByIds(userIds).stream()
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toMap(User::getId, User::getUserName, (a, b) -> a));
|
||||
}
|
||||
}
|
||||
|
|
@ -24,42 +24,11 @@ public class QmsIssueTicketAddAndDispatchQO {
|
|||
*/
|
||||
private String projectNo;
|
||||
|
||||
/**
|
||||
* 事故类型:0=一般,1=较严重,2=严重
|
||||
*/
|
||||
@NotNull(message = "事故类型不能为空")
|
||||
private Short incidentType;
|
||||
|
||||
/**
|
||||
* 异常代码
|
||||
*/
|
||||
private String exceptionCode;
|
||||
|
||||
/**
|
||||
* 影响数量
|
||||
*/
|
||||
private String impactQuantity;
|
||||
|
||||
/**
|
||||
* 事件地点
|
||||
*/
|
||||
private String incidentLocation;
|
||||
|
||||
/**
|
||||
* 事件描述
|
||||
*/
|
||||
private String incidentDescription;
|
||||
|
||||
/**
|
||||
* 事件原因
|
||||
*/
|
||||
private String incidentReason;
|
||||
|
||||
/**
|
||||
* 事件后果
|
||||
*/
|
||||
private String incidentConsequence;
|
||||
|
||||
/**
|
||||
* 图片列表
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -0,0 +1,23 @@
|
|||
package com.nflg.wms.common.pojo.qo;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* QMS负责人配置新增参数
|
||||
*/
|
||||
@Data
|
||||
public class QmsPrincipalAddQO {
|
||||
|
||||
/**
|
||||
* 负责人用户ID
|
||||
*/
|
||||
@NotNull(message = "用户ID不能为空")
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* QMS用户类型
|
||||
*/
|
||||
@NotNull(message = "QMS用户类型不能为空")
|
||||
private Integer qmsUserType;
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
package com.nflg.wms.common.pojo.qo;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* QMS负责人配置查询参数
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class QmsPrincipalSearchQO extends PageQO {
|
||||
|
||||
/**
|
||||
* 负责人姓名(可选,模糊匹配)
|
||||
*/
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* QMS用户类型(可选)
|
||||
*/
|
||||
private Integer qmsUserType;
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
package com.nflg.wms.common.pojo.qo;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* QMS负责人配置更新参数
|
||||
*/
|
||||
@Data
|
||||
public class QmsPrincipalUpdateQO {
|
||||
|
||||
/**
|
||||
* 数据ID
|
||||
*/
|
||||
@NotNull(message = "ID不能为空")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* QMS用户类型
|
||||
*/
|
||||
@NotNull(message = "QMS用户类型不能为空")
|
||||
private Integer qmsUserType;
|
||||
}
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
package com.nflg.wms.common.pojo.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* QMS负责人配置返回对象
|
||||
*/
|
||||
@Data
|
||||
public class QmsPrincipalVO {
|
||||
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 负责人用户ID
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 负责人姓名
|
||||
*/
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* QMS用户类型
|
||||
*/
|
||||
private Integer qmsUserType;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private Long createBy;
|
||||
|
||||
/**
|
||||
* 创建人姓名
|
||||
*/
|
||||
private String createByName;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
private Long updateBy;
|
||||
|
||||
/**
|
||||
* 修改人姓名
|
||||
*/
|
||||
private String updateByName;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
}
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
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;
|
||||
|
||||
/**
|
||||
* QMS负责人配置
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@Accessors(chain = true)
|
||||
@TableName("qms_principal")
|
||||
public class QmsPrincipal implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "id", type = IdType.ASSIGN_ID)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 负责人用户ID
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* QMS用户类型
|
||||
*/
|
||||
private Integer qmsUserType;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private Long createBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
private Long updateBy;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
package com.nflg.wms.repository.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.nflg.wms.repository.entity.QmsPrincipal;
|
||||
|
||||
/**
|
||||
* QMS负责人配置 Mapper 接口
|
||||
*/
|
||||
public interface QmsPrincipalMapper extends BaseMapper<QmsPrincipal> {
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
package com.nflg.wms.repository.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.nflg.wms.repository.entity.QmsPrincipal;
|
||||
|
||||
/**
|
||||
* QMS负责人配置 服务类
|
||||
*/
|
||||
public interface IQmsPrincipalService extends IService<QmsPrincipal> {
|
||||
}
|
||||
|
|
@ -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.QmsPrincipal;
|
||||
import com.nflg.wms.repository.mapper.QmsPrincipalMapper;
|
||||
import com.nflg.wms.repository.service.IQmsPrincipalService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* QMS负责人配置 服务实现类
|
||||
*/
|
||||
@Service
|
||||
public class QmsPrincipalServiceImpl extends ServiceImpl<QmsPrincipalMapper, QmsPrincipal>
|
||||
implements IQmsPrincipalService {
|
||||
}
|
||||
Loading…
Reference in New Issue