fix: 87480 企业标准-自动生成顺序号有问题

This commit is contained in:
2024-07-24 17:03:08 +08:00
parent 9421a38f22
commit defba9de90
6 changed files with 6 additions and 330 deletions
@@ -1,8 +1,7 @@
package com.jero.modules.laws.enterprise.service;
import com.jero.modules.laws.enterprise.entity.EnterpriseStandardAuthDept;
import com.baomidou.mybatisplus.extension.service.IService;
import com.jero.modules.laws.standard.entity.LawsStandardTempPermission;
import com.jero.modules.laws.enterprise.entity.EnterpriseStandardAuthDept;
import java.util.List;
@@ -13,7 +12,5 @@ import java.util.List;
*/
public interface EnterpriseStandardAuthDeptService extends IService<EnterpriseStandardAuthDept> {
void saveTempPermission(LawsStandardTempPermission lawsStandardTempPermission);
void batchInsertWithTransaction(List<EnterpriseStandardAuthDept> list, int batchSize);
}
@@ -1,10 +1,9 @@
package com.jero.modules.laws.enterprise.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.jero.modules.laws.enterprise.entity.EnterpriseStandardAuthUser;
import com.baomidou.mybatisplus.extension.service.IService;
import com.jero.modules.laws.enterprise.entity.EnterpriseStandardAuthUser;
import com.jero.modules.laws.standard.controller.TempAuthRecordQueryDto;
import com.jero.modules.laws.standard.entity.LawsStandardTempPermission;
import java.util.List;
import java.util.Map;
@@ -16,15 +15,6 @@ import java.util.Map;
*/
public interface EnterpriseStandardAuthUserService extends IService<EnterpriseStandardAuthUser> {
void saveTempPermission(LawsStandardTempPermission lawsStandardTempPermission);
/**
* 不校验当前登陆人账号是否有权限
*
* @param lawsStandardTempPermission
*/
void saveTempPermissionTwo(LawsStandardTempPermission lawsStandardTempPermission);
/**
* 查看详情权限设置
*
@@ -48,16 +38,6 @@ public interface EnterpriseStandardAuthUserService extends IService<EnterpriseSt
boolean detailPermissionByUser(String standardId, String standardNumber, String userId);
boolean verifyESDeleteAuth(String ids, String userId);
/**
* 企标编辑保存后 重置授权部门
*
* @param id
* @param string
*/
void resetAuthDept(String id, String string);
/**
* 临时授权记录分页列表接口
*
@@ -75,15 +55,6 @@ public interface EnterpriseStandardAuthUserService extends IService<EnterpriseSt
*/
void revokeAuth(String authId);
boolean hasESAuth(String userId, List<String> standardIds);
/**
* 指定用户Id是否有指定企标的删除权限
* @param standardId 企标Id
* @param userId 用户Id
*/
boolean hasDelAuth(String standardId, String userId);
/**
* 指定用户Id是否有指定企标的删除权限
* @param standardId 企标Id
@@ -97,10 +68,4 @@ public interface EnterpriseStandardAuthUserService extends IService<EnterpriseSt
*/
void isEditHorizontalOverstep(String standardId);
/**
* 删除水平越权校验
* @param standardId 企标Id
*/
void isDeleteHorizontalOverstep(String standardId);
}
@@ -34,40 +34,9 @@ import java.util.List;
public class EnterpriseStandardAuthDeptServiceImpl extends ServiceImpl<EnterpriseStandardAuthDeptMapper, EnterpriseStandardAuthDept>
implements EnterpriseStandardAuthDeptService{
@Resource
private ILawsEnterpriseStandardService enterpriseStandardService;
@Resource
private EnterpriseStandardAuthUserServiceImpl authUserService;
@Resource
private SqlSessionFactory sqlSessionFactory;
@Override
public void saveTempPermission(LawsStandardTempPermission lawsStandardTempPermission) {
List<String> standardIdList = lawsStandardTempPermission.getStandardIdList();
for (String id : standardIdList) {
if (!authUserService.hasESAuth(UserUtils.getUserId(), Collections.singletonList(id))) {
LawsEnterpriseStandard es = enterpriseStandardService.getById(id);
throw new JeroBootException(MessageUtils.getMessage(ResultCommon.YOU_HAVE_NOT_DATA_AUTH, es.getStandardNumber()));
}
}
List<EnterpriseStandardAuthDept> esAuthDepts = new ArrayList<>();
for (String standardId : lawsStandardTempPermission.getStandardIdList()) {
for (String deptId : lawsStandardTempPermission.getDeptIdList()) {
EnterpriseStandardAuthDept enterpriseStandardAuthDept = new EnterpriseStandardAuthDept();
enterpriseStandardAuthDept.setAuthDept(deptId);
enterpriseStandardAuthDept.setStandardId(standardId);
if (lawsStandardTempPermission.getAuthDate() != null) {
enterpriseStandardAuthDept.setAuthExpireDate(lawsStandardTempPermission.getAuthDate());
}
esAuthDepts.add(enterpriseStandardAuthDept);
}
}
saveBatch(esAuthDepts);
}
@Override
public void batchInsertWithTransaction(List<EnterpriseStandardAuthDept> list, int batchSize) {
@@ -97,56 +97,6 @@ public class EnterpriseStandardAuthUserServiceImpl extends ServiceImpl<Enterpris
@Resource
private ISysDepartService departService;
@Override
public void saveTempPermission(LawsStandardTempPermission lawsStandardTempPermission) {
List<String> standardIdList = lawsStandardTempPermission.getStandardIdList();
for (String id : standardIdList) {
if (!this.hasESAuth(UserUtils.getUserId(), Collections.singletonList(id))) {
LawsEnterpriseStandard es = enterpriseStandardService.getById(id);
throw new JeroBootException(MessageUtils.getMessage(ResultCommon.YOU_HAVE_NOT_DATA_AUTH, es.getStandardNumber()));
}
}
List<EnterpriseStandardAuthUser> esAuthUsers = new ArrayList<>();
for (String standardId : lawsStandardTempPermission.getStandardIdList()) {
for (String userId : lawsStandardTempPermission.getUserIdList()) {
EnterpriseStandardAuthUser enterpriseStandardAuthUser = new EnterpriseStandardAuthUser();
enterpriseStandardAuthUser.setAuthUser(userId);
enterpriseStandardAuthUser.setStandardId(standardId);
if (lawsStandardTempPermission.getAuthDate() != null) {
Date authDate = lawsStandardTempPermission.getAuthDate();
// 对authDate加一天
Calendar c = Calendar.getInstance();
c.setTime(authDate);
c.add(Calendar.DATE, 1);
authDate = c.getTime();
enterpriseStandardAuthUser.setAuthExpireDate(authDate);
}
esAuthUsers.add(enterpriseStandardAuthUser);
}
}
saveBatch(esAuthUsers);
}
@Override
public void saveTempPermissionTwo(LawsStandardTempPermission lawsStandardTempPermission) {
List<EnterpriseStandardAuthUser> esAuthUsers = new ArrayList<>();
for (String standardId : lawsStandardTempPermission.getStandardIdList()) {
for (String userId : lawsStandardTempPermission.getUserIdList()) {
EnterpriseStandardAuthUser enterpriseStandardAuthUser = new EnterpriseStandardAuthUser();
enterpriseStandardAuthUser.setAuthUser(userId);
enterpriseStandardAuthUser.setStandardId(standardId);
enterpriseStandardAuthUser.setAuthExpireDate(lawsStandardTempPermission.getAuthDate());
esAuthUsers.add(enterpriseStandardAuthUser);
}
}
saveBatch(esAuthUsers);
}
@Override
public void detailFlagSet(List<Map<String, Object>> records) {
if (true) {
@@ -242,95 +192,6 @@ public class EnterpriseStandardAuthUserServiceImpl extends ServiceImpl<Enterpris
}
@Override
public boolean hasESAuth(String userId, List<String> standardIds) {
SysUser currentUser = sysUserService.getById(userId);
// 管理员有所有企标的权限
List<String> roleList = sysUserRoleService.getRole(currentUser.getUsername());
if (roleList != null && roleList.stream().anyMatch(adminRoleCodeList::contains)) {
return true;
}
List<Map<String, Object>> records = new ArrayList<>();
for (String id : standardIds) {
Map<String, Object> map = new HashMap<>();
map.put(FieldCommon.ID, id);
records.add(map);
}
List<DepartIdModel> departIdModels = sysUserDepartService.queryDepartIdsOfUser(userId);
List<String> departIds = departIdModels.stream().map(DepartIdModel::getKey).collect(Collectors.toList());
List<String> departNames = departIdModels.stream().map(DepartIdModel::getTitle).collect(Collectors.toList());
List<LawsEnterpriseStandard> esList = enterpriseStandardService.list(new LambdaQueryWrapper<LawsEnterpriseStandard>()
.in(CollUtil.isNotEmpty(standardIds), LawsEnterpriseStandard::getId, standardIds)
.eq(LawsEnterpriseStandard::getDelFlag, YesOrNoEnum.NO.getValue()));
Map<String, LawsEnterpriseStandard> esMap = esList.stream().collect(Collectors.toMap(LawsEnterpriseStandard::getId, e -> e));
// 查询临时授权人员
Date date = new Date();
LambdaQueryWrapper<EnterpriseStandardAuthUser> authUserWrapper = new LambdaQueryWrapper<>();
authUserWrapper.in(CollUtil.isNotEmpty(standardIds), EnterpriseStandardAuthUser::getStandardId, standardIds);
authUserWrapper.eq(EnterpriseStandardAuthUser::getAuthUser, userId);
authUserWrapper.ge(EnterpriseStandardAuthUser::getAuthExpireDate, date);
List<EnterpriseStandardAuthUser> authUserList = list(authUserWrapper);
Set<String> tempAuthStandardIds = authUserList.stream().map(EnterpriseStandardAuthUser::getStandardId).collect(Collectors.toSet());
// 查询临时授权部门
LambdaQueryWrapper<EnterpriseStandardAuthDept> tempAuthDeptWrapper = new LambdaQueryWrapper<>();
tempAuthDeptWrapper.in(CollUtil.isNotEmpty(standardIds), EnterpriseStandardAuthDept::getStandardId, standardIds);
tempAuthDeptWrapper.in(CollUtil.isNotEmpty(departIds), EnterpriseStandardAuthDept::getAuthDept, departIds);
tempAuthDeptWrapper.isNotNull(EnterpriseStandardAuthDept::getAuthExpireDate);
tempAuthDeptWrapper.isNotNull(EnterpriseStandardAuthDept::getAuthDept);
List<EnterpriseStandardAuthDept> tempAuthDeptList = authDeptService.list(tempAuthDeptWrapper);
tempAuthDeptWrapper.ge(EnterpriseStandardAuthDept::getAuthExpireDate, date);
tempAuthDeptList.addAll(authDeptService.list(tempAuthDeptWrapper));
// 找出授权部门 和 临时授权部门
tempAuthStandardIds.addAll(tempAuthDeptList.stream().map(EnterpriseStandardAuthDept::getStandardId).collect(Collectors.toSet()));
// 查询授权部门
LambdaQueryWrapper<EnterpriseStandardAuthDept> authDeptWrapper = new LambdaQueryWrapper<>();
authDeptWrapper.in(CollUtil.isNotEmpty(standardIds), EnterpriseStandardAuthDept::getStandardId, standardIds);
authDeptWrapper.isNull(EnterpriseStandardAuthDept::getAuthExpireDate);
List<EnterpriseStandardAuthDept> authDeptList = authDeptService.list(authDeptWrapper);
authDeptList.addAll(authDeptService.list(authDeptWrapper));
// 企标级别授权的部门
List<LawsEnterpriseStandardLevel> standardLevelList = standardLevelService.list();
List<LawsGrade> gradeList = gradeService.list();
Map<Integer, LawsGrade> gradeMap = gradeList.stream().collect(Collectors.toMap(LawsGrade::getLevel, e -> e));
List<String> levelOneDeptIds = standardLevelList.stream().filter(l -> l.getGradeId().equals(gradeMap.get(1).getId()))
.map(LawsEnterpriseStandardLevel::getDeptId).collect(Collectors.toList());
List<String> levelTwoDeptIds = standardLevelList.stream().filter(l -> l.getGradeId().equals(gradeMap.get(2).getId()))
.map(LawsEnterpriseStandardLevel::getDeptId).collect(Collectors.toList());
// 获取起草部门的Id
for (Map<String, Object> map : records) {
String standardId = (String) map.get(FieldCommon.ID);
LawsEnterpriseStandard es = esMap.get(standardId);
String mainDraftUnit = es.getMainDraftingUnit();
Set<EnterpriseStandardAuthDept> curAuthSet = authDeptList.stream()
.filter(e -> e.getAuthDept() != null)
.filter(e -> StrUtil.isNotEmpty(e.getAuthDept()))
.filter(e -> e.getStandardId().equals(standardId))
.filter(e -> !e.getAuthDept().equals(mainDraftUnit))
.collect(Collectors.toSet());
// 临时权限
if (tempAuthStandardIds.contains(standardId)) {
map.put(FieldCommon.DETAIL_FLAG, true);
continue;
}
map.put(FieldCommon.DETAIL_FLAG, false);
}
// 遍历map
for (
Map<String, Object> map : records) {
if (!(boolean) map.get(FieldCommon.DETAIL_FLAG)) {
return false;
}
}
return true;
}
@Override
public void editFlagSet(List<Map<String, Object>> records) {
@@ -358,49 +219,6 @@ public class EnterpriseStandardAuthUserServiceImpl extends ServiceImpl<Enterpris
}
}
@Override
public boolean hasDelAuth(String standardId, String userId) {
SysUser currentUser = sysUserService.getById(userId);
String username = currentUser.getUsername();
LawsEnterpriseStandard es = enterpriseStandardService.getById(standardId);
Date currentDate = new Date();
// 获取当前用户的角色roleCode
List<String> roleList = sysUserRoleService.getRole(currentUser.getUsername());
// 管理员能够删除所有试用期的企标
if (roleList != null && roleList.stream().anyMatch(adminRoleCodeList::contains)) {
String tryFlag = es.getTryFlag();
if (tryFlag.equals(YesOrNoEnum.NO.getValue())) {
return false;
}
Date releaseDate = es.getReleaseDate();
int trialPeriodMonths = Integer.parseInt(es.getTrialPeriod()); // 将试用周期转换为天数
Calendar calendar = Calendar.getInstance();
calendar.setTime(releaseDate);
calendar.add(Calendar.MONTH, trialPeriodMonths); // 将试用周期加到发布日期上
Date trialEndDate = calendar.getTime(); // 获取试用期结束日期
// 在适用周期之内的可以删除
return tryFlag.equals(YesOrNoEnum.YES.getValue()) && currentDate.compareTo(trialEndDate) <= 0;
}
// 创建人只能删除自己的试用期的企标
String createBy = es.getCreateBy();
String tryFlag = es.getTryFlag();
if (tryFlag.equals(YesOrNoEnum.NO.getValue())) {
return false;
}
Date releaseDate = es.getReleaseDate();
int trialPeriodMonths = Integer.parseInt(es.getTrialPeriod()); // 将试用周期转换为天数
Calendar calendar = Calendar.getInstance();
calendar.setTime(releaseDate);
calendar.add(Calendar.MONTH, trialPeriodMonths); // 将试用周期加到发布日期上
Date trialEndDate = calendar.getTime(); // 获取试用期结束日期
return username.equals(createBy) && tryFlag.equals(YesOrNoEnum.YES.getValue())
&& currentDate.compareTo(trialEndDate) <= 0;
}
@Override
public boolean hasEditAuth(String standardId, String userId) {
SysUser user = sysUserService.getById(userId);
@@ -423,14 +241,6 @@ public class EnterpriseStandardAuthUserServiceImpl extends ServiceImpl<Enterpris
throw new JeroBootException(MessageUtils.getMessage(ResultCommon.YOU_HAVE_NOT_DATA_AUTH, standardId));
}
@Override
public void isDeleteHorizontalOverstep(String standardId) {
if (hasDelAuth(standardId, UserUtils.getUserId())) {
return;
}
throw new JeroBootException(MessageUtils.getMessage(ResultCommon.YOU_HAVE_NOT_DATA_AUTH, standardId));
}
@Override
public void delFlagSet(List<Map<String, Object>> records) {
if (true) {
@@ -554,49 +364,6 @@ public class EnterpriseStandardAuthUserServiceImpl extends ServiceImpl<Enterpris
return false;
}
/**
* 校验用户是否有删除权限
*
* @param ids
* @param userId
* @return
*/
public boolean verifyESDeleteAuth(String ids, String userId) {
if (StringUtils.isBlank(ids)) {
throw new JeroBootException(ResultCommon.EMPTY_COMMON, "ids不能为空");
}
String[] idList = ids.split(",");
for (String id : idList) {
boolean auth = this.hasDelAuth(id, userId);
if (!auth) {
return false;
}
}
return true;
}
@Override
public void resetAuthDept(String id, String authDept) {
// 逗号拼接转换List
String[] authDeptIdList = authDept.split(",");
// 先删后增
LambdaQueryWrapper<EnterpriseStandardAuthDept> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(EnterpriseStandardAuthDept::getStandardId, id);
authDeptService.remove(wrapper);
List<EnterpriseStandardAuthDept> authDeptList = new ArrayList<>();
if (authDeptIdList.length == 0) {
return;
}
for (String deptId : authDeptIdList) {
EnterpriseStandardAuthDept authDept1 = new EnterpriseStandardAuthDept();
authDept1.setStandardId(id);
authDept1.setAuthDept(deptId);
authDeptList.add(authDept1);
}
authDeptService.saveBatch(authDeptList);
}
@Override
@Cacheable(value = "tempAuthRecord", key = "{#tempAuthRecordQueryDto, #pageNo, #pageSize}")
public IPage<TempAuthRecordQueryDto> tempAuthRecord(TempAuthRecordQueryDto tempAuthRecordQueryDto, Integer pageNo, Integer pageSize) {
@@ -201,16 +201,16 @@ public class EnterpriseStandardUtil {
if (dashIndex == -1) {
dashIndex = standardNo.lastIndexOf('—');
}
if (dashIndex < 4) {
return null; // 如果没有找到'-',或者'-'前面的字符少于4
if (dashIndex < 3) {
return null; // 如果没有找到'-',或者'-'前面的字符少于3
}
int dotIndex = standardNo.lastIndexOf('.');
if (dotIndex > 0 && dotIndex < dashIndex) { // 确保小数点在破折号前且存在
int start = Math.max(dotIndex - 4, 0); // 确保不会有负索引
int start = Math.max(dotIndex - 3, 0); // 确保不会有负索引
return standardNo.substring(start, dashIndex); // 提取包含小数点的序列号部分
} else {
return standardNo.substring(dashIndex - 4, dashIndex); // 如果没有小数点,应用原有逻辑
return standardNo.substring(dashIndex - 3, dashIndex); // 如果没有小数点,应用原有逻辑
}
}
@@ -15,7 +15,6 @@ import com.jero.modules.laws.enterprise.entity.EnterpriseStandardRmrEvaluateDeta
import com.jero.modules.laws.enterprise.service.EnterpriseStandardAuthDeptService;
import com.jero.modules.laws.enterprise.service.EnterpriseStandardAuthUserService;
import com.jero.modules.laws.enterprise.service.EnterpriseStandardReviewMeetingRecordService;
import com.jero.modules.laws.standard.entity.LawsStandardTempPermission;
import com.jero.modules.laws.standard.service.ILawsNodeRelationService;
import com.jero.modules.personal.service.ILawsStandardCollectionService;
import com.jero.modules.split.service.ISarFileSplitInfoService;
@@ -35,7 +34,6 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
import java.util.Objects;
/**
* @Author: liao
@@ -181,8 +179,6 @@ public class LawsEnterpriseController {
@ApiOperationSupport(order = 9)
@RequiresPermissions("enterpriseStandard:delete")
public Result<String> singleDelete(@RequestBody @ApiParam(name = "ids", value = "主键(多个用逗号分隔)") Map<String,Object> parameterMap) {
// 水平越权校验
esAuthUserService.isDeleteHorizontalOverstep((String) parameterMap.get("ids"));
// 检查是否在企标更改流程中,如果在流程中则不允许删除
// esChangeService.delCheck((String) parameterMap.get("ids"));
// 删除标准时同步删除这个标准的收藏数据
@@ -215,24 +211,6 @@ public class LawsEnterpriseController {
return Result.OK(MessageUtils.getMessage(ResultCommon.OK));
}
@AutoLog(value = "企业法规标准-临时权限设置")
@ApiOperation(value="企业法规标准-临时权限设置", notes="企业法规标准-临时权限设置")
@PostMapping(value = "/tempPermission")
@ApiOperationSupport(order = 13)
@RequiresPermissions("enterpriseStandard:temporaryPermissSet")
@CacheEvict(value = "tempAuthRecord", allEntries = true)
public Result<?> tempPermission(@RequestBody LawsStandardTempPermission lawsStandardTempPermission) {
String userIds = lawsStandardTempPermission.getUserIds();
String deptIds = lawsStandardTempPermission.getDeptIds();
if (Objects.nonNull(userIds) && !userIds.isEmpty()) {
esAuthUserService.saveTempPermission(lawsStandardTempPermission);
}
if (Objects.nonNull(deptIds) && !deptIds.isEmpty()) {
esAuthDeptService.saveTempPermission(lawsStandardTempPermission);
}
return Result.OK();
}
/**
* 企标评价
*