试验管理

This commit is contained in:
cwchen 2024-07-23 09:43:14 +08:00
parent ba9a224e85
commit 27469e94ce
10 changed files with 108 additions and 9 deletions

View File

@ -1,7 +1,10 @@
package com.bonus.aqgqj.basis.entity.dto; package com.bonus.aqgqj.basis.entity.dto;
import com.bonus.aqgqj.base.entity.PageEntity; import com.bonus.aqgqj.base.entity.PageEntity;
import com.bonus.aqgqj.utils.UserUtil;
import lombok.Data; import lombok.Data;
import org.apache.catalina.User;
import org.apache.commons.lang3.StringUtils;
/** /**
* @className:ParamsDto * @className:ParamsDto
@ -42,4 +45,18 @@ public class ParamsDto extends PageEntity {
*/ */
private Long[] ids; private Long[] ids;
/**
* 角色编码
*/
private String roleCode = UserUtil.getLoginUser() !=null && StringUtils.isNotBlank(UserUtil.getLoginUser().getRoleCode()) ? UserUtil.getLoginUser().getRoleCode() : null;
/**
* 班组ID
*/
private String teamId = UserUtil.getLoginUser() !=null && StringUtils.isNotBlank(UserUtil.getLoginUser().getTeamId()) ? UserUtil.getLoginUser().getTeamId() : "-1";
/**
* 是否是班组长
*/
private String isTeamLeader = UserUtil.getLoginUser() !=null && StringUtils.isNotBlank(UserUtil.getLoginUser().getIsTeamLeader()) ? UserUtil.getLoginUser().getIsTeamLeader() : "0";
} }

View File

@ -60,7 +60,7 @@ public class ExperConfigVo {
* 创建人 * 创建人
*/ */
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY) @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private Long createUser = UserUtil.getLoginUser().getId(); private Long createUser = UserUtil.getLoginUser() !=null ? UserUtil.getLoginUser().getId() : -1;
/** /**
* 创建时间 * 创建时间
*/ */
@ -71,7 +71,7 @@ public class ExperConfigVo {
* 修改人 * 修改人
*/ */
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY) @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private Long updateUser = UserUtil.getLoginUser().getId(); private Long updateUser = UserUtil.getLoginUser() !=null ? UserUtil.getLoginUser().getId() : -1;
/** /**
* 修改时间 * 修改时间
*/ */

View File

@ -123,7 +123,7 @@ public class TestVo {
* 创建人 * 创建人
*/ */
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY) @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private Long createUser = UserUtil.getLoginUser().getId(); private Long createUser = UserUtil.getLoginUser() !=null ? UserUtil.getLoginUser().getId() : -1;
/** /**
* 创建时间 * 创建时间
*/ */
@ -134,7 +134,7 @@ public class TestVo {
* 修改人 * 修改人
*/ */
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY) @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private Long updateUser = UserUtil.getLoginUser().getId(); private Long updateUser = UserUtil.getLoginUser() !=null ? UserUtil.getLoginUser().getId() : -1;
/** /**
* 修改时间 * 修改时间
*/ */

View File

@ -360,4 +360,5 @@ public class ExperimentStandardServiceImpl implements ExperimentStandardService
} }
return null; return null;
} }
} }

View File

@ -10,6 +10,7 @@ import com.bonus.aqgqj.basis.entity.vo.*;
import com.bonus.aqgqj.basis.service.ExperimentalService; import com.bonus.aqgqj.basis.service.ExperimentalService;
import com.bonus.aqgqj.utils.DateTimeHelper; import com.bonus.aqgqj.utils.DateTimeHelper;
import com.bonus.aqgqj.utils.ServerResponse; import com.bonus.aqgqj.utils.ServerResponse;
import com.bonus.aqgqj.utils.SystemUtils;
import com.bonus.aqgqj.webResult.Constants; import com.bonus.aqgqj.webResult.Constants;
import com.bonus.aqgqj.webResult.HttpStatus; import com.bonus.aqgqj.webResult.HttpStatus;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -124,6 +125,9 @@ public class ExperimentalServiceImpl implements ExperimentalService {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public ServerResponse addTestData(TestVo vo) { public ServerResponse addTestData(TestVo vo) {
try { try {
if(!SystemUtils.isExperimentalTeam()){
return ServerResponse.createByErrorMsg(HttpStatus.ERROR, "非试验班组,无法添加试验数据");
}
// 整体数据校验数据 // 整体数据校验数据
String validResult = validatorsUtils.valid(vo, TestVo.Query.class); String validResult = validatorsUtils.valid(vo, TestVo.Query.class);
if (StringUtils.isNotBlank(validResult)) { if (StringUtils.isNotBlank(validResult)) {
@ -194,6 +198,9 @@ public class ExperimentalServiceImpl implements ExperimentalService {
if(vo.getId() == null){ if(vo.getId() == null){
return ServerResponse.createByErrorMsg(HttpStatus.ERROR, "参数不完整"); return ServerResponse.createByErrorMsg(HttpStatus.ERROR, "参数不完整");
} }
if(!SystemUtils.isExperimentalTeam()){
return ServerResponse.createByErrorMsg(HttpStatus.ERROR, "非试验班组,无法修改试验数据");
}
// 处于审核流程中的数据无法进行修改 // 处于审核流程中的数据无法进行修改
int isCheck = mapper.isCheck(vo.getId()); int isCheck = mapper.isCheck(vo.getId());
if(isCheck > 0){ if(isCheck > 0){
@ -323,6 +330,9 @@ public class ExperimentalServiceImpl implements ExperimentalService {
if(dto.getIds() == null || dto.getIds().length == 0){ if(dto.getIds() == null || dto.getIds().length == 0){
return ServerResponse.createByErrorMsg(HttpStatus.ERROR,"未提交审查数据"); return ServerResponse.createByErrorMsg(HttpStatus.ERROR,"未提交审查数据");
} }
if(!SystemUtils.isExperimentalTeam()){
return ServerResponse.createByErrorMsg(HttpStatus.ERROR, "非试验班组,无法提交审查数据");
}
// 判断提交数据中是否存在流程数据或者存在待试验项 // 判断提交数据中是否存在流程数据或者存在待试验项
List<Long> list = Arrays.asList(dto.getIds()); List<Long> list = Arrays.asList(dto.getIds());
int result = mapper.isNotEditData(list); int result = mapper.isNotEditData(list);

View File

@ -115,6 +115,8 @@ public class SysUser extends PageEntity {
private String roleCode; private String roleCode;
/**班组ID*/ /**班组ID*/
private String teamId; private String teamId;
/**是否是班组长*/
private String isTeamLeader;
public interface Status { public interface Status {

View File

@ -1,9 +1,13 @@
package com.bonus.aqgqj.utils; package com.bonus.aqgqj.utils;
import com.bonus.aqgqj.webResult.Constants;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.Objects;
@Component @Component
@Slf4j @Slf4j
public class SystemUtils { public class SystemUtils {
@ -63,9 +67,51 @@ public class SystemUtils {
} }
} }
/**
* 是否是试验班组-试验人员
* @return Boolean
* @author cwchen
* @date 2024/7/23 9:30
*/
public static Boolean isExperimentalTeam(){
if(UserUtil.getLoginUser() == null){
return false;
}
String roleCode = StringUtils.isNotBlank(UserUtil.getLoginUser().getRoleCode()) ? UserUtil.getLoginUser().getRoleCode() : null;
String teamId = StringUtils.isNotBlank(UserUtil.getLoginUser().getTeamId()) ? UserUtil.getLoginUser().getTeamId() : "-1";
String isTeamLeader = StringUtils.isNotBlank(UserUtil.getLoginUser().getIsTeamLeader()) ? UserUtil.getLoginUser().getIsTeamLeader() : "0";
if(Objects.equals(Constants.EXPERIMENTALTEAM,roleCode)
&& !Objects.equals(Constants.VALUE_DATA,teamId)
&& Objects.equals(isTeamLeader,Constants.VALUE_DATA2)){
return true;
}else if(Objects.equals(Constants.ADMIDMINISTRATORS,roleCode) ){
return true;
}else{
return false;
}
}
/**
* 是否是试验班组-班组长
* @return Boolean
* @author cwchen
* @date 2024/7/23 9:30
*/
public static Boolean isExperimentalTeamLeader(){
if(UserUtil.getLoginUser() == null){
return false;
}
String roleCode = StringUtils.isNotBlank(UserUtil.getLoginUser().getRoleCode()) ? UserUtil.getLoginUser().getRoleCode() : null;
String teamId = StringUtils.isNotBlank(UserUtil.getLoginUser().getTeamId()) ? UserUtil.getLoginUser().getTeamId() : "-1";
String isTeamLeader = StringUtils.isNotBlank(UserUtil.getLoginUser().getIsTeamLeader()) ? UserUtil.getLoginUser().getIsTeamLeader() : "0";
if(Objects.equals(Constants.EXPERIMENTALTEAM,roleCode)
&& !Objects.equals(Constants.VALUE_DATA,teamId)
&& Objects.equals(isTeamLeader,Constants.VALUE_DATA3)){
return true;
}else if(Objects.equals(Constants.ADMIDMINISTRATORS,roleCode) ){
return true;
}else{
return false;
}
}
} }

View File

@ -144,5 +144,20 @@ public class Constants
public static final String ERROR_RESULT2 = "不通过"; public static final String ERROR_RESULT2 = "不通过";
public static final String SUCCESS_RESULT = "合格"; public static final String SUCCESS_RESULT = "合格";
/**管理员*/
public static final String ADMIDMINISTRATORS = "administrators";
/**技术负责人*/
public static final String TECHNICALDIRECTOR = "technicalDirector";
/**中心负责人*/
public static final String CENTERTRALMANAGER = "centerManager";
/**试验班组*/
public static final String EXPERIMENTALTEAM = "experimentalTeam";
/**综合班组*/
public static final String INTEGRATEDTEAM = "integratedTeam";
public static final String VALUE_DATA = "-1";
public static final String VALUE_DATA2 = "0";
public static final String VALUE_DATA3 = "1";
} }

View File

@ -293,6 +293,14 @@
<if test="devTypeCode != null and devTypeCode!=''"> <if test="devTypeCode != null and devTypeCode!=''">
AND INSTR(tsd.sampleDevCode,#{devTypeCode}) AND INSTR(tsd.sampleDevCode,#{devTypeCode})
</if> </if>
<if test="roleCode != 'administrators'">
<if test="roleCode == 'experimentalTeam' and teamId != '-1' and isTeamLeader == '0'">
AND ts.team_id = #{teamId}
</if>
<if test="(roleCode != 'experimentalTeam') or (roleCode == 'experimentalTeam' and teamId != '-1' and isTeamLeader == '1')">
AND ts.team_id = -1
</if>
</if>
ORDER BY FIELD(audtiStatus, '审阅不通过','审核不通过','审批不通过','待试验','待提交','待审阅','待审核','待审批','试验结束') ASC,dispatch_time ASC ORDER BY FIELD(audtiStatus, '审阅不通过','审核不通过','审批不通过','待试验','待提交','待审阅','待审核','待审批','试验结束') ASC,dispatch_time ASC
</select> </select>
<!--试验详情列表--> <!--试验详情列表-->

View File

@ -50,7 +50,7 @@
<select id="getUser" parameterType="String" resultType="com.bonus.aqgqj.model.SysUser"> <select id="getUser" parameterType="String" resultType="com.bonus.aqgqj.model.SysUser">
select t.id,t.user_name as username,t.login_name as loginName, select t.id,t.user_name as username,t.login_name as loginName,
t.password,t.state,t.role_id as roleId,t.login_type loginType,t.new_user newUser, t.password,t.state,t.role_id as roleId,t.login_type loginType,t.new_user newUser,
sr.role_code AS roleCode,sr.role_name AS roleName,t.team_id AS teamId sr.role_code AS roleCode,sr.role_name AS roleName,t.team_id AS teamId,t.is_team_leader AS isTeamLeader
from sys_user t from sys_user t
LEFT JOIN sys_role sr ON t.role_id = sr.role_id AND sr.del_flag = 0 LEFT JOIN sys_role sr ON t.role_id = sr.role_id AND sr.del_flag = 0
where t.login_name = #{username} where t.login_name = #{username}