studio数据权限

This commit is contained in:
zhn
2023-08-25 16:26:31 +08:00
parent 7bb3fffe7f
commit 3a5c0938a0
@@ -13,7 +13,6 @@ import com.jero.modules.ota.entity.OtaManageApplyEO;
import com.jero.modules.ota.entity.OtaManageHistory;
import com.jero.modules.ota.entity.OtaManagePermission;
import com.jero.modules.ota.entity.OtaManageReceive;
import com.jero.modules.ota.entity.OtaManageReceiveNsdpEO;
import com.jero.modules.ota.enums.OtaCarEnum;
import com.jero.modules.ota.enums.OtaHomoImpactEnum;
import com.jero.modules.ota.enums.OtaStatusEnum;
@@ -30,10 +29,12 @@ import com.jero.modules.ota.vo.OtaExportCnVO;
import com.jero.modules.ota.vo.OtaExportEnVO;
import com.jero.modules.ota.vo.VersionVO;
import com.jero.modules.project.entity.ProjectLibraryBase;
import com.jero.modules.project.entity.ProjectNameInfoEO;
import com.jero.modules.project.entity.ProjectTaskPlanning;
import com.jero.modules.project.enums.CertificationProgressEnum;
import com.jero.modules.project.enums.ComplianceFlowStatusEnum;
import com.jero.modules.project.service.IProjectLibraryBaseService;
import com.jero.modules.project.service.impl.ProjectNameInfoEOServiceImpl;
import com.jero.modules.project.service.impl.ProjectTaskPlanningServiceImpl;
import com.jero.modules.system.entity.SysDictItem;
import com.jero.modules.system.entity.SysUser;
@@ -60,7 +61,6 @@ import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import java.text.Collator;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
@@ -108,6 +108,8 @@ public class OtaManageApplyEOServiceImpl extends ServiceImpl<OtaManageApplyEOMap
@Autowired
private ISysDictService sysDictService;
@Autowired
private ProjectNameInfoEOServiceImpl projectNameInfoEOService;
@Value(value = "${jero.path.upload}")
private String upLoadPath;
@@ -296,6 +298,10 @@ public class OtaManageApplyEOServiceImpl extends ServiceImpl<OtaManageApplyEOMap
@Override
public List<OtaManageApplyEO> getAllCarPage(OtaManageApplyEO otaManageApplyEO) {
List<OtaManageApplyEO> otaManageApplyEOList = this.getBaseMapper().getOtaList(otaManageApplyEO);
//studio数据权限
if(isStudio()) {
otaManageApplyEOList = getStudioData(otaManageApplyEO, otaManageApplyEOList);
}
if (!otaManageApplyEOList.isEmpty()) {
for (OtaManageApplyEO manageApplyEO : otaManageApplyEOList) {
manageApplyEO.setVdr(manageApplyEO.getId());
@@ -306,6 +312,42 @@ public class OtaManageApplyEOServiceImpl extends ServiceImpl<OtaManageApplyEOMap
return otaManageApplyEOList;
}
private List<OtaManageApplyEO> getStudioData(OtaManageApplyEO otaManageApplyEO, List<OtaManageApplyEO> otaManageApplyEOList) {
List<OtaManageApplyEO> list = new ArrayList<>();
List<String> studioCarList = getStudioCarList(otaManageApplyEO.getPlannedBpLaunchBatch());
for (String carMarket : studioCarList) {
String[] conditionSplit = carMarket.split(" ");
for (OtaManageApplyEO manageApplyEO : otaManageApplyEOList) {
String appliedVehicleProject = manageApplyEO.getAppliedVehicleProject();
if (StringUtils.isNotBlank(appliedVehicleProject)) {
String[] appliedVehicleProjectArr = appliedVehicleProject.split(",");
for (String appliedVehicleProjectTemp : appliedVehicleProjectArr) {
String[] split = appliedVehicleProjectTemp.split(" ");
if (split.length == 1) {
list.add(manageApplyEO);
break;
} else if (split.length == 2) {
if (Arrays.equals(conditionSplit, split)) {
list.add(manageApplyEO);
break;
}
} else if (split.length == 3) {
List<String> listTemp = Arrays.asList(split);
List<String> conditionList = Arrays.asList(conditionSplit);
if (listTemp.containsAll(conditionList)) {
list.add(manageApplyEO);
break;
}
}
}
}
}
}
otaManageApplyEOList= list;
return otaManageApplyEOList;
}
private void heartSort(OtaManageApplyEO otaManageApplyEO, List<OtaManageApplyEO> otaManageApplyEOList) {
Collator comparator = Collator.getInstance(Locale.CHINESE);
// 软件版本,
@@ -646,8 +688,14 @@ public class OtaManageApplyEOServiceImpl extends ServiceImpl<OtaManageApplyEOMap
String[] conditionSplit = carMarket.split(" ");
for (OtaManageApplyEO manageApplyEO : otaManageApplyEOList) {
if (StringUtils.isNotEmpty(manageApplyEO.getVehicleType()) && !manageApplyEO.getVehicleType().equals(otaManageApplyEO.getAppliedVehicleProject())) {
continue;
if (StringUtils.isNotEmpty(manageApplyEO.getVehicleType())
&& !manageApplyEO.getVehicleType().equals(otaManageApplyEO.getAppliedVehicleProject())) {
manageApplyEO.setVehicleType(otaManageApplyEO.getAppliedVehicleProject());
manageApplyEO.setId(UUID.randomUUID().toString().replace("-", ""));
manageApplyEO.setProjectVersion(null);
manageApplyEO.setAttestationSchedule(null);
manageApplyEO.setMatchStatus(null);
manageApplyEO.setRemark("--");
}
if (StringUtils.isEmpty(manageApplyEO.getId()) || manageApplyEO.getId().length() < 20) {
manageApplyEO.setId(UUID.randomUUID().toString().replace("-", ""));
@@ -832,6 +880,40 @@ public class OtaManageApplyEOServiceImpl extends ServiceImpl<OtaManageApplyEOMap
*/
@Override
public List<String> getCarList(String cut, String plannedBpLaunchBatch) {
Set<String> set = new HashSet<>();
if(isStudio()){
List<ProjectNameInfoEO> nameInfoEOList = projectNameInfoEOService.list();
List<DictModel> targetMarketList = sysDictService.queryDictItemsByCode(DicCodeEnum.REGION.getCode());
LoginUser currentUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
//studio在项目库所拥有的权限的项目
LambdaQueryWrapper<ProjectLibraryBase> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(ProjectLibraryBase::getStudioEngineer,currentUser.getId());
List<ProjectLibraryBase> libraryBaseList = projectLibraryBaseService.list(wrapper);
for (ProjectLibraryBase projectLibraryBase : libraryBaseList) {
String carId = projectLibraryBase.getProjectNameId();
String marketId = projectLibraryBase.getTargetMarket();
List<ProjectNameInfoEO> projectNameInfoEOList = nameInfoEOList.stream().filter(e -> e.getId().equals(carId)).collect(Collectors.toList());
String finalMarket = marketId;
List<DictModel> dictModelList = targetMarketList.stream().filter(e -> e.getValue().equals(finalMarket)).collect(Collectors.toList());
if(!projectNameInfoEOList.isEmpty() && !dictModelList.isEmpty()){
String market = dictModelList.get(0).getTextEn();
if ("China".equals(market)) {
//项目库里市场存的是China 不是CN
market = "CN";
} else if ("UK".equals(market)) {
//RHD目前代表UK
market = "RHD";
}
String car = projectNameInfoEOList.get(0).getProjectName();
if("FORCE".equals(car)){
car = "Force";
}
set.add(car + " " + market);
}
}
}
List<OtaManageApplyEO> otaManageApplyEOS = this.getBaseMapper().getOtaCarList(plannedBpLaunchBatch);
List<String> result = new LinkedList<>();
if (CutEnum.CN.getValue().equals(cut)) {
@@ -862,6 +944,75 @@ public class OtaManageApplyEOServiceImpl extends ServiceImpl<OtaManageApplyEOMap
}
}
result = result.stream().distinct().collect(Collectors.toList());
if(isStudio()){
result.retainAll(set);
if (CutEnum.CN.getValue().equals(cut)) {
result.add("全部");
} else {
result.add("All");
}
}
return result;
}
public List<String> getStudioCarList(String plannedBpLaunchBatch) {
Set<String> set = new HashSet<>();
List<ProjectNameInfoEO> nameInfoEOList = projectNameInfoEOService.list();
List<DictModel> targetMarketList = sysDictService.queryDictItemsByCode(DicCodeEnum.REGION.getCode());
LoginUser currentUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
//studio在项目库所拥有的权限的项目
LambdaQueryWrapper<ProjectLibraryBase> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(ProjectLibraryBase::getStudioEngineer, currentUser.getId());
List<ProjectLibraryBase> libraryBaseList = projectLibraryBaseService.list(wrapper);
for (ProjectLibraryBase projectLibraryBase : libraryBaseList) {
String carId = projectLibraryBase.getProjectNameId();
String marketId = projectLibraryBase.getTargetMarket();
List<ProjectNameInfoEO> projectNameInfoEOList = nameInfoEOList.stream().filter(e -> e.getId().equals(carId)).collect(Collectors.toList());
String finalMarket = marketId;
List<DictModel> dictModelList = targetMarketList.stream().filter(e -> e.getValue().equals(finalMarket)).collect(Collectors.toList());
if (!projectNameInfoEOList.isEmpty() && !dictModelList.isEmpty()) {
String market = dictModelList.get(0).getTextEn();
if ("China".equals(market)) {
//项目库里市场存的是China 不是CN
market = "CN";
} else if ("UK".equals(market)) {
//RHD目前代表UK
market = "RHD";
}
String car = projectNameInfoEOList.get(0).getProjectName();
if("FORCE".equals(car)){
car = "Force";
}
set.add(car + " " + market);
}
}
List<OtaManageApplyEO> otaManageApplyEOS = this.getBaseMapper().getOtaCarList(plannedBpLaunchBatch);
List<String> result = new LinkedList<>();
if (!otaManageApplyEOS.isEmpty()) {
//适用车型 appliedVehicleProject
List<String> appliedVehicleProjectList = otaManageApplyEOS.stream()
.filter(e -> StringUtils.isNotBlank(e.getAppliedVehicleProject()))
.map(OtaManageApplyEO::getAppliedVehicleProject).distinct().collect(Collectors.toList());
//过滤掉特殊的适用车型
List<String> otaNameList = OtaCarEnum.getOtaNameList();
for (String appliedVehicleProject : appliedVehicleProjectList) {
for (String s : appliedVehicleProject.split(",")) {
String[] split = s.split(" ");
if (split.length == 2) {
if (!otaNameList.contains(s)) {
result.add(s);
}
} else if (split.length == 3) {
result.add(split[0] + " " + split[2]);
}
}
}
}
result = result.stream().distinct().collect(Collectors.toList());
result.retainAll(set);
return result;
}