项目库-法规清单表 开发。

This commit is contained in:
wangzhijiang
2022-04-14 18:09:35 +08:00
parent 79255de6db
commit 0225504cd0
7 changed files with 458 additions and 46 deletions
@@ -35,7 +35,7 @@ import com.jero.common.aspect.annotation.AutoLog;
public class ProjectLawsInventoryEOController extends JeroController<ProjectLawsInventoryEO, IProjectLawsInventoryEOService> {
@Autowired
private IProjectLawsInventoryEOService projectLawsInventoryEOService;
/**
* 分页列表查询
*
@@ -66,8 +66,8 @@ public class ProjectLawsInventoryEOController extends JeroController<ProjectLaws
@AutoLog(value = "项目库-法规清单表-列表查询")
@ApiOperation(value="项目库-法规清单表-列表查询", notes="项目库-法规清单表-列表查询")
@GetMapping(value = "/list")
public Result<List<ProjectLawsInventoryEO>> queryList() {
List<ProjectLawsInventoryEO> list = projectLawsInventoryEOService.queryList();
public Result<List<ProjectLawsInventoryEO>> queryList(ProjectLawsInventoryEO projectLawsInventoryEO) {
List<ProjectLawsInventoryEO> list = projectLawsInventoryEOService.queryList(projectLawsInventoryEO);
return Result.OK(list);
}
@@ -3,7 +3,10 @@ package com.jero.modules.project.entity;
import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
@@ -35,200 +38,237 @@ public class ProjectLawsInventoryEO implements Serializable {
/**主键*/
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "主键")
private java.lang.String id;
private String id;
/**创建人*/
@ApiModelProperty(value = "创建人")
private java.lang.String createBy;
private String createBy;
/**创建日期*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "创建日期")
private java.util.Date createTime;
private Date createTime;
/**更新人*/
@ApiModelProperty(value = "更新人")
private java.lang.String updateBy;
private String updateBy;
/**更新日期*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "更新日期")
private java.util.Date updateTime;
private Date updateTime;
/**所属部门*/
@ApiModelProperty(value = "所属部门")
private java.lang.String sysOrgCode;
private String sysOrgCode;
/**项目库id*/
@Excel(name = "项目库id", width = 15)
@ApiModelProperty(value = "项目库id")
private java.lang.String projectLibraryId;
private String projectLibraryId;
/**编号*/
@Excel(name = "编号", width = 15)
@ApiModelProperty(value = "编号")
private java.lang.String serialNumber;
private String serialNumber;
/**标题*/
@Excel(name = "标题", width = 15)
@ApiModelProperty(value = "标题")
private java.lang.String title;
private String title;
/**子标题*/
@Excel(name = "子标题", width = 15)
@ApiModelProperty(value = "子标题")
private java.lang.String subtitle;
private String subtitle;
/**对应标准*/
@Excel(name = "对应标准", width = 15)
@ApiModelProperty(value = "对应标准")
private java.lang.String correspondingStandard;
private String correspondingStandard;
/**实施类别*/
@Excel(name = "实施类别", width = 15)
@ApiModelProperty(value = "实施类别")
private java.lang.String implementType;
private String implementType;
/**新车型实施日期*/
@Excel(name = "新车型实施日期", width = 15, format = "yyyy-MM-dd")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
@ApiModelProperty(value = "新车型实施日期")
private java.util.Date xin1Che1Xing2Shi2Shi1Ri4Qi1;
private Date xin1Che1Xing2Shi2Shi1Ri4Qi1;
/**在产车实施日期*/
@Excel(name = "在产车实施日期", width = 15, format = "yyyy-MM-dd")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
@ApiModelProperty(value = "在产车实施日期")
private java.util.Date implementTime;
private Date implementTime;
/**认证类型*/
@Excel(name = "认证类型", width = 15)
@ApiModelProperty(value = "认证类型")
private java.lang.String attestationType;
private String attestationType;
/**认证级别*/
@Excel(name = "认证级别", width = 15)
@ApiModelProperty(value = "认证级别")
private java.lang.String attestationRank;
private String attestationRank;
/**WVTA ID*/
@Excel(name = "WVTA ID", width = 15)
@ApiModelProperty(value = "WVTA ID")
private java.lang.String wvtaId;
private String wvtaId;
/**责任领域*/
@Excel(name = "责任领域", width = 15)
@ApiModelProperty(value = "责任领域")
private java.lang.String dutyTerritory;
private String dutyTerritory;
/**法规工程师id*/
@Excel(name = "法规工程师id", width = 15)
@ApiModelProperty(value = "法规工程师id")
private java.lang.String regulationOwnerId;
private String regulationOwnerId;
@TableField(exist = false)
@ApiModelProperty(value = "法规工程师名称")
private String regulationOwnerName;//法规工程师名称
/**认证工程师id*/
@Excel(name = "认证工程师id", width = 15)
@ApiModelProperty(value = "认证工程师id")
private java.lang.String homologationEngineerId;
private String homologationEngineerId;
@TableField(exist = false)
@ApiModelProperty(value = "认证工程师名称")
private String homologationEngineerName;//认证工程师名称
/**工程接口人id*/
@Excel(name = "工程接口人id", width = 15)
@ApiModelProperty(value = "工程接口人id")
private java.lang.String engineeringInterfacePerson;
private String engineeringInterfacePerson;
@TableField(exist = false)
@ApiModelProperty(value = "工程接口人名称")
private String engineeringInterfacePersonName;//工程接口人名称
/**备注*/
@Excel(name = "备注", width = 15)
@ApiModelProperty(value = "备注")
private java.lang.String remark;
private String remark;
/**设计符合性确认-交付物类型*/
@Excel(name = "设计符合性确认-交付物类型", width = 15)
@ApiModelProperty(value = "设计符合性确认-交付物类型")
private java.lang.String designDeliverableType;
private String designDeliverableType;
/**设计符合性确认-交付物模板*/
@Excel(name = "设计符合性确认-交付物模板", width = 15)
@ApiModelProperty(value = "设计符合性确认-交付物模板")
private java.lang.String designDeliverableTemplate;
private String designDeliverableTemplate;
/**设计符合性确认-发起人*/
@Excel(name = "设计符合性确认-发起人", width = 15)
@ApiModelProperty(value = "设计符合性确认-发起人")
private java.lang.String designInitiator;
private String designInitiator;
/**设计符合性确认-责任人*/
@Excel(name = "设计符合性确认-责任人", width = 15)
@ApiModelProperty(value = "设计符合性确认-责任人")
private java.lang.String designDuty;
private String designDuty;
/**设计符合性确认-截止时间*/
@Excel(name = "设计符合性确认-截止时间", width = 15, format = "yyyy-MM-dd")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
@ApiModelProperty(value = "设计符合性确认-截止时间")
private java.util.Date designDueDate;
private Date designDueDate;
/**prehomo确认-交付物类型*/
@Excel(name = "prehomo确认-交付物类型", width = 15)
@ApiModelProperty(value = "prehomo确认-交付物类型")
private java.lang.String prehomoDeliverableType;
private String prehomoDeliverableType;
/**prehomo确认-交付物模板*/
@Excel(name = "prehomo确认-交付物模板", width = 15)
@ApiModelProperty(value = "prehomo确认-交付物模板")
private java.lang.String prehomoDeliverableTemplate;
private String prehomoDeliverableTemplate;
/**prehomo确认-发起人*/
@Excel(name = "prehomo确认-发起人", width = 15)
@ApiModelProperty(value = "prehomo确认-发起人")
private java.lang.String prehomoInitiator;
private String prehomoInitiator;
/**prehomo确认-责任人*/
@Excel(name = "prehomo确认-责任人", width = 15)
@ApiModelProperty(value = "prehomo确认-责任人")
private java.lang.String prehomoDuty;
private String prehomoDuty;
/**prehomo确认-截止时间*/
@Excel(name = "prehomo确认-截止时间", width = 15, format = "yyyy-MM-dd")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
@ApiModelProperty(value = "prehomo确认-截止时间")
private java.util.Date prehomoDueDate;
private Date prehomoDueDate;
/**验证符合性确认-交付物类型*/
@Excel(name = "验证符合性确认-交付物类型", width = 15)
@ApiModelProperty(value = "验证符合性确认-交付物类型")
private java.lang.String verifyDeliverableType;
private String verifyDeliverableType;
/**验证符合性确认-交付物模板*/
@Excel(name = "验证符合性确认-交付物模板", width = 15)
@ApiModelProperty(value = "验证符合性确认-交付物模板")
private java.lang.String verifyDeliverableTemplate;
private String verifyDeliverableTemplate;
/**验证符合性确认-发起人*/
@Excel(name = "验证符合性确认-发起人", width = 15)
@ApiModelProperty(value = "验证符合性确认-发起人")
private java.lang.String verifyInitiator;
private String verifyInitiator;
/**验证符合性确认-责任人*/
@Excel(name = "验证符合性确认-责任人", width = 15)
@ApiModelProperty(value = "验证符合性确认-责任人")
private java.lang.String verifyDuty;
private String verifyDuty;
/**验证符合性确认-截止时间*/
@Excel(name = "验证符合性确认-截止时间", width = 15, format = "yyyy-MM-dd")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
@ApiModelProperty(value = "验证符合性确认-截止时间")
private java.util.Date verifyDueDate;
private Date verifyDueDate;
/**清单确认状态*/
@Excel(name = "清单确认状态", width = 15)
@ApiModelProperty(value = "清单确认状态")
private String inventoryAffirmStatus;
@TableField(exist = false)
@ApiModelProperty(value = "清单确认状态名称")
private String inventoryAffirmStatusName;//清单确认状态名称
/**任务发布状态*/
@Excel(name = "任务发布状态", width = 15)
@ApiModelProperty(value = "任务发布状态")
private java.lang.String taskReleaseStatus;
private String taskAffirmStatus;
@TableField(exist = false)
@ApiModelProperty(value = "任务发布状态名称")
private String taskAffirmStatusName;//任务发布状态名称
@TableField(exist = false)
@ApiModelProperty(value = "角色代码")
private String roleCode;//角色代码
@TableField(exist = false)
@ApiModelProperty(value = "角色名称")
private String roleName;//角色名称
/**法规工程师提交状态 :0通过 1驳回 */
@ApiModelProperty(value = "法规工程师提交状态")
private String regulationOwnerSubmitStatus;
//这两个只要有一个是拒绝 那么该数据的清单确认状态就为拒绝
/**认证工程师提交状态 :0通过 1驳回 */
@ApiModelProperty(value = "认证工程师提交状态")
private String homologationEngineerSubmitStatus;
}
@@ -0,0 +1,56 @@
package com.jero.modules.project.enums;
/**
* 清单确认状态枚举类
*/
public enum InventoryAffirmStatusEnum {
/**
* 未发起:数据刚创建时,状态为
* 待确认:studio工程师发起清单确认后
* 接受:认证工程师、法规工程师两个人都提交通过, 则状态为 接受,该数据则可以发起任务确认流程
* 拒绝:认证工程师、法规工程师两个人其中有一个拒绝 则状态为拒绝,studio工程师可以对这条数据再次发起清单确认
*/
NOT_STARTED("未发起","Not started"),
LIST_TO_CONFIRM("待确认","List to confirm"),
ACCEPTED("接受","accepted"),
REJECTED("拒绝","rejected"),
;
String name;
String value;
private InventoryAffirmStatusEnum(String name, String value) {
this.name = name;
this.value = value;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public static String getTextByValue(String value) {
InventoryAffirmStatusEnum[] values = values();
for (InventoryAffirmStatusEnum inventoryAffirmStatusEnum : values) {
if (inventoryAffirmStatusEnum.value.equals(value)) {
return inventoryAffirmStatusEnum.name;
}
}
return null;
}
}
@@ -0,0 +1,47 @@
package com.jero.modules.project.enums;
/**
* 项目角色枚举类
*/
public enum ProjectRoleEnum {
STUDIO_ENGINEER("studio工程师","0"),
REGULATI_ENGINEER("法规工程师","1"),
HOMOLOGATION_ENGINEER("认证工程师","2"),
ENGINEERING_INTERFACE_PERSON("工程接口人","3"),
REGULATI_AND_HOMOLOGATION_ENGINEER("法规与认证工程师","4"),
;
String name;
String value;
private ProjectRoleEnum(String name, String value) {
this.name = name;
this.value = value;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public static String getTextByValue(String value) {
ProjectRoleEnum[] values = values();
for (ProjectRoleEnum projectRoleEnum : values) {
if (projectRoleEnum.value.equals(value)) {
return projectRoleEnum.name;
}
}
return null;
}
}
@@ -0,0 +1,57 @@
package com.jero.modules.project.enums;
/**
* 任务确认状态枚举类
*/
public enum TaskAffirmStatusEnum {
/**
* 未发起:数据刚创建时
* 清单待确认:studio工程师发起清单确认后
* 清单确认:法规工程师、认证工程师,两个人都编辑成功后
* 任务发布:
* 任务接受:studio工程师发起任务确认,流程走完后,责任人二次确认后 如果通过 则状态为任务接受,同时发起设计符合性审查流程、prehomo流程、验证符合性审查流程 三个流程
* 任务拒绝:studio工程师发起任务确认,流程走完后,责任人二次确认后 如果拒绝 则状态为任务拒绝,studio工程师可以对这条数据再次发起任务确认流程
*/
NOT_STARTED("未发起","Not started"),
LIST_TO_CONFIRM("待确认","List to confirm"),
ACCEPTED("接受","accepted"),
REJECTED("拒绝","rejected"),
;
String name;
String value;
private TaskAffirmStatusEnum(String name, String value) {
this.name = name;
this.value = value;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public static String getTextByValue(String value) {
TaskAffirmStatusEnum[] values = values();
for (TaskAffirmStatusEnum taskAffirmStatusEnum : values) {
if (taskAffirmStatusEnum.value.equals(value)) {
return taskAffirmStatusEnum.name;
}
}
return null;
}
}
@@ -57,5 +57,5 @@ public interface IProjectLawsInventoryEOService extends IService<ProjectLawsInve
*
* @return
*/
List<ProjectLawsInventoryEO> queryList();
List<ProjectLawsInventoryEO> queryList(ProjectLawsInventoryEO projectLawsInventoryEO);
}
@@ -1,11 +1,29 @@
package com.jero.modules.project.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jero.common.exception.JeroBootException;
import com.jero.common.system.vo.LoginUser;
import com.jero.modules.project.entity.ProjectLawsInventoryEO;
import com.jero.modules.project.entity.ProjectLibraryBase;
import com.jero.modules.project.enums.ProjectRoleEnum;
import com.jero.modules.project.enums.InventoryAffirmStatusEnum;
import com.jero.modules.project.enums.TaskAffirmStatusEnum;
import com.jero.modules.project.mapper.ProjectLawsInventoryEOMapper;
import com.jero.modules.project.mapper.ProjectLibraryBaseMapper;
import com.jero.modules.project.service.IProjectLawsInventoryEOService;
import com.jero.modules.system.entity.SysUser;
import com.jero.modules.system.mapper.SysUserMapper;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Date;
import java.util.stream.Collectors;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
/**
@@ -17,6 +35,12 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@Service
public class ProjectLawsInventoryEOServiceImpl extends ServiceImpl<ProjectLawsInventoryEOMapper, ProjectLawsInventoryEO> implements IProjectLawsInventoryEOService {
@Autowired
private ProjectLibraryBaseMapper projectLibraryBaseMapper;
@Autowired
private SysUserMapper sysUserMapper;
/**
* 保存
*
@@ -28,6 +52,8 @@ public class ProjectLawsInventoryEOServiceImpl extends ServiceImpl<ProjectLawsIn
Date now = new Date();
projectLawsInventoryEO.setCreateTime(now);
projectLawsInventoryEO.setUpdateTime(now);
projectLawsInventoryEO.setTaskAffirmStatus(TaskAffirmStatusEnum.NOT_STARTED.getValue());
projectLawsInventoryEO.setInventoryAffirmStatus(InventoryAffirmStatusEnum.NOT_STARTED.getValue());
save(projectLawsInventoryEO);
}
@@ -40,8 +66,14 @@ public class ProjectLawsInventoryEOServiceImpl extends ServiceImpl<ProjectLawsIn
@Override
public void editById(ProjectLawsInventoryEO projectLawsInventoryEO) {
Date now = new Date();
projectLawsInventoryEO.setUpdateTime(now);
saveOrUpdate(projectLawsInventoryEO);
LoginUser currentUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
boolean checkResult = checkData(projectLawsInventoryEO.getProjectLibraryId(), currentUser.getId(), projectLawsInventoryEO.getId());
if(checkResult){
projectLawsInventoryEO.setUpdateTime(now);
saveOrUpdate(projectLawsInventoryEO);
}else {
throw new JeroBootException("该用户没有权限操作该数据!");
}
}
/**
@@ -83,7 +115,187 @@ public class ProjectLawsInventoryEOServiceImpl extends ServiceImpl<ProjectLawsIn
* @return
*/
@Override
public List<ProjectLawsInventoryEO> queryList() {
return list();
public List<ProjectLawsInventoryEO> queryList(ProjectLawsInventoryEO projectLawsInventoryEO) {
String projectLibraryId = projectLawsInventoryEO.getProjectLibraryId();
if(StringUtils.isEmpty(projectLibraryId)){
throw new JeroBootException("项目库id不能为空!");
}
LoginUser currentUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
QueryWrapper<ProjectLawsInventoryEO> projectLawsInventoryEOQueryWrapper = new QueryWrapper<>();
projectLawsInventoryEOQueryWrapper.lambda().eq(ProjectLawsInventoryEO::getProjectLibraryId,projectLibraryId);
//验证当前用户在该项目中是什么角色
int isProjectRole = checkUserRole(projectLibraryId, currentUser.getId(), "");
if(isProjectRole != Integer.parseInt(ProjectRoleEnum.STUDIO_ENGINEER.getValue())){
projectLawsInventoryEOQueryWrapper.lambda().eq(ProjectLawsInventoryEO::getHomologationEngineerId,currentUser.getId());
projectLawsInventoryEOQueryWrapper.lambda().or().eq(ProjectLawsInventoryEO::getRegulationOwnerId,currentUser.getId());
}
List<ProjectLawsInventoryEO> result = super.baseMapper.selectList(projectLawsInventoryEOQueryWrapper);
dataDispose(result,currentUser,isProjectRole);
return result;
}
/**
* 数据处理
* @param list
*/
public void dataDispose(List<ProjectLawsInventoryEO> list,LoginUser currentUser,int isProjectRole){
if(CollectionUtils.isNotEmpty(list)){
List<String> userIdList = new ArrayList<>();
for (ProjectLawsInventoryEO projectLawsInventoryEO : list) {
if(StringUtils.isNotEmpty(projectLawsInventoryEO.getHomologationEngineerId())){
userIdList.add(projectLawsInventoryEO.getHomologationEngineerId());
}
if(StringUtils.isNotEmpty(projectLawsInventoryEO.getRegulationOwnerId())){
userIdList.add(projectLawsInventoryEO.getRegulationOwnerId());
}
if(StringUtils.isNotEmpty(projectLawsInventoryEO.getEngineeringInterfacePerson())){
userIdList.add(projectLawsInventoryEO.getEngineeringInterfacePerson());
}
}
List<SysUser> sysUsers = new ArrayList<>();
if(CollectionUtils.isNotEmpty(userIdList)){
userIdList = userIdList.stream().distinct().collect(Collectors.toList());
QueryWrapper<SysUser> sysUserQueryWrapper = new QueryWrapper<>();
sysUserQueryWrapper.lambda().in(SysUser::getId,userIdList);
sysUsers = sysUserMapper.selectList(sysUserQueryWrapper);
}
for (ProjectLawsInventoryEO projectLawsInventoryEO : list) {
//处理人员展示名称
if(CollectionUtils.isNotEmpty(sysUsers)){
String homologationEngineerId = projectLawsInventoryEO.getHomologationEngineerId();
if(StringUtils.isNotEmpty(homologationEngineerId)){
String homologationEngineerName = sysUsers.stream().filter(e -> homologationEngineerId.equals(e.getId())).
map(SysUser::getRealname).collect(Collectors.joining(","));
projectLawsInventoryEO.setHomologationEngineerName(homologationEngineerName);
}
String regulationOwnerId = projectLawsInventoryEO.getRegulationOwnerId();
if(StringUtils.isNotEmpty(regulationOwnerId)){
String regulationOwnerName = sysUsers.stream().filter(e -> regulationOwnerId.equals(e.getId())).
map(SysUser::getRealname).collect(Collectors.joining(","));
projectLawsInventoryEO.setRegulationOwnerName(regulationOwnerName);
}
String engineeringInterfacePerson = projectLawsInventoryEO.getEngineeringInterfacePerson();
if(StringUtils.isNotEmpty(engineeringInterfacePerson)){
String engineeringInterfacePersonName = sysUsers.stream().filter(e -> engineeringInterfacePerson.equals(e.getId())).
map(SysUser::getRealname).collect(Collectors.joining(","));
projectLawsInventoryEO.setEngineeringInterfacePersonName(engineeringInterfacePersonName);
}
}
//清单确认状态
String inventoryAffirmStatus = projectLawsInventoryEO.getInventoryAffirmStatus();
if(StringUtils.isNotEmpty(inventoryAffirmStatus)){
projectLawsInventoryEO.setInventoryAffirmStatusName(InventoryAffirmStatusEnum.getTextByValue(inventoryAffirmStatus));
}
//任务确认状态
String taskAffirmStatus = projectLawsInventoryEO.getTaskAffirmStatus();
if(StringUtils.isNotEmpty(taskAffirmStatus)){
projectLawsInventoryEO.setTaskAffirmStatusName(InventoryAffirmStatusEnum.getTextByValue(taskAffirmStatus));
}
String roleCode = "";
String roleName = "";
//设置当前用户在该项目中的角色
if(isProjectRole == Integer.parseInt(ProjectRoleEnum.STUDIO_ENGINEER.getValue())){
roleCode = ProjectRoleEnum.STUDIO_ENGINEER.getValue();
roleName = ProjectRoleEnum.STUDIO_ENGINEER.getName();
}else {
if(StringUtils.equals(currentUser.getId(),projectLawsInventoryEO.getRegulationOwnerId())
&&StringUtils.equals(currentUser.getId(),projectLawsInventoryEO.getHomologationEngineerId())){
roleCode = ProjectRoleEnum.REGULATI_AND_HOMOLOGATION_ENGINEER.getValue();
roleName = ProjectRoleEnum.REGULATI_AND_HOMOLOGATION_ENGINEER.getName();
}else if(StringUtils.equals(currentUser.getId(),projectLawsInventoryEO.getRegulationOwnerId())){
roleCode = ProjectRoleEnum.REGULATI_ENGINEER.getValue();
roleName = ProjectRoleEnum.REGULATI_ENGINEER.getName();
}else if(StringUtils.equals(currentUser.getId(),projectLawsInventoryEO.getHomologationEngineerId())){
roleCode = ProjectRoleEnum.HOMOLOGATION_ENGINEER.getValue();
roleName = ProjectRoleEnum.HOMOLOGATION_ENGINEER.getName();
}
}
projectLawsInventoryEO.setRoleCode(roleCode);
projectLawsInventoryEO.setRoleName(roleName);
}
}
}
/**
* 验证数据
* @param projectLibraryId 项目id
* @param lawsInventoryId 法规详情id
* @param currentUserId 当前登录人id
* @return
*/
public boolean checkData(String projectLibraryId, String currentUserId,String lawsInventoryId){
boolean result = false;
try{
QueryWrapper<ProjectLawsInventoryEO> queryWrapper = new QueryWrapper<>();
int isProjectRole = checkUserRole(projectLibraryId, currentUserId,lawsInventoryId);
if(isProjectRole != Integer.parseInt(ProjectRoleEnum.STUDIO_ENGINEER.getValue())){
queryWrapper.lambda().eq(ProjectLawsInventoryEO::getHomologationEngineerId,currentUserId);
queryWrapper.lambda().or().eq(ProjectLawsInventoryEO::getRegulationOwnerId,currentUserId);
}
queryWrapper.lambda().eq(ProjectLawsInventoryEO::getId,lawsInventoryId);
Integer projectLawsInventoryCount = super.baseMapper.selectCount(queryWrapper);
if(projectLawsInventoryCount > 0){
result = true;
}
}catch (Exception ex){
log.error("验证项目库-法规清单表数据异常:" + ex.getMessage());
throw new JeroBootException("验证项目库-法规清单表数据异常!");
}
return result;
}
/**
* 验证用户在该项目中的角色
* @param projectLibraryId 项目库id
* @param currentUserId 登录人id
* @param lawsInventoryId 法规清单id
* @return
*/
public int checkUserRole(String projectLibraryId,String currentUserId,String lawsInventoryId){
int result = -1;
try{
QueryWrapper<ProjectLibraryBase> projectLibraryBaseQueryWrapper = new QueryWrapper<>();
projectLibraryBaseQueryWrapper.lambda().eq(ProjectLibraryBase::getId,projectLibraryId);
projectLibraryBaseQueryWrapper.lambda().eq(ProjectLibraryBase::getStudioEngineer,currentUserId);
Integer projectLibrayBaseCount = projectLibraryBaseMapper.selectCount(projectLibraryBaseQueryWrapper);
if(projectLibrayBaseCount > 0){
result = Integer.parseInt(ProjectRoleEnum.STUDIO_ENGINEER.getValue());
}else {
if(StringUtils.isNotEmpty(lawsInventoryId)){
//查询用户是否是法规工程师
QueryWrapper<ProjectLawsInventoryEO> queryWrapperFG = new QueryWrapper<>();
queryWrapperFG.lambda().eq(ProjectLawsInventoryEO::getRegulationOwnerId,currentUserId);
queryWrapperFG.lambda().eq(ProjectLawsInventoryEO::getId,lawsInventoryId);
Integer lawsInventoryCountFG = super.baseMapper.selectCount(queryWrapperFG);
QueryWrapper<ProjectLawsInventoryEO> queryWrapperRZ = new QueryWrapper<>();
queryWrapperRZ.lambda().eq(ProjectLawsInventoryEO::getHomologationEngineerId,currentUserId);
queryWrapperRZ.lambda().eq(ProjectLawsInventoryEO::getId,lawsInventoryId);
Integer lawsInventoryCountRZ = super.baseMapper.selectCount(queryWrapperRZ);
//如果两个工程师都是这个用户
if(lawsInventoryCountFG > 0 && lawsInventoryCountRZ > 0){
result = Integer.parseInt(ProjectRoleEnum.REGULATI_AND_HOMOLOGATION_ENGINEER.getValue());
}else if(lawsInventoryCountFG > 0){
result = Integer.parseInt(ProjectRoleEnum.REGULATI_ENGINEER.getValue());
}else if(lawsInventoryCountRZ > 0){
result = Integer.parseInt(ProjectRoleEnum.HOMOLOGATION_ENGINEER.getValue());
}
}
}
}catch (Exception ex){
log.error("验证用户在该项目中的角色失败:" + ex.getMessage());
throw new JeroBootException("验证用户在该项目中的角色失败!");
}
return result;
}
}