修改OTA批量编辑

This commit is contained in:
高嵩
2023-08-25 00:14:18 +08:00
parent 2f931ae002
commit 180d1e94b1
@@ -1093,6 +1093,17 @@ public class OtaManageApplyEOServiceImpl extends ServiceImpl<OtaManageApplyEOMap
return StringUtils.equals(str1, str2); return StringUtils.equals(str1, str2);
} }
private Map<String, String> queryProjectName(List<OtaManageApplyEO> list) {
Map<String, String> res = new HashMap<>();
List<String> idList = list.stream()
.filter(e -> StringUtils.isNotBlank(e.getProjectVersion()))
.map(OtaManageApplyEO::getProjectVersion).distinct().collect(Collectors.toList());
List<ProjectLibraryBase> proList = projectLibraryBaseService.queryList(idList);
for (ProjectLibraryBase plb : proList) {
res.put(plb.getId(), plb.getShowName());
}
return res;
}
@Override @Override
public void temporarySave(List<OtaManageApplyEO> list, String cut) { public void temporarySave(List<OtaManageApplyEO> list, String cut) {
@@ -1104,6 +1115,10 @@ public class OtaManageApplyEOServiceImpl extends ServiceImpl<OtaManageApplyEOMap
//已存在的数据 //已存在的数据
List<OtaManageApplyEO> omaOldList = this.getBaseMapper().selectBatchIds(idList); List<OtaManageApplyEO> omaOldList = this.getBaseMapper().selectBatchIds(idList);
List<OtaManageApplyEO> queryProNameList = new ArrayList<>();
queryProNameList.addAll(omaOldList);
queryProNameList.addAll(list);
Map<String, String> proNameMap = queryProjectName(queryProNameList);
//历史记录 //历史记录
List<OtaManageHistory> hisList = new ArrayList<>(); List<OtaManageHistory> hisList = new ArrayList<>();
List<OtaManageApplyEO> saveList = new ArrayList<>(); List<OtaManageApplyEO> saveList = new ArrayList<>();
@@ -1127,7 +1142,7 @@ public class OtaManageApplyEOServiceImpl extends ServiceImpl<OtaManageApplyEOMap
conSb.append(user.getUsername()).append(" : "); conSb.append(user.getUsername()).append(" : ");
conSbEn.append(user.getUsername()).append(" : "); conSbEn.append(user.getUsername()).append(" : ");
if (!paramsEquals(oma.getProjectVersion(), omaOld.getProjectVersion())) { if (!paramsEquals(oma.getProjectVersion(), omaOld.getProjectVersion())) {
conSb.append("‘项目版本’ 由 ‘").append(omaOld.getProjectVersionText()).append("’ 改为 ‘").append(oma.getProjectVersionText()).append("‘."); conSb.append("‘项目版本’ 由 ‘").append(proNameMap.get(omaOld.getProjectVersion())).append("’ 改为 ‘").append(proNameMap.get(oma.getProjectVersion())).append("‘.");
conSbEn.append("‘Project Version‘ change from ‘").append(omaOld.getProjectVersionText()).append("‘ to ‘").append(oma.getProjectVersionText()).append("‘."); conSbEn.append("‘Project Version‘ change from ‘").append(omaOld.getProjectVersionText()).append("‘ to ‘").append(oma.getProjectVersionText()).append("‘.");
} }
if (!paramsEquals(oma.getAttestationSchedule(), omaOld.getAttestationSchedule())) { if (!paramsEquals(oma.getAttestationSchedule(), omaOld.getAttestationSchedule())) {
@@ -1158,8 +1173,8 @@ public class OtaManageApplyEOServiceImpl extends ServiceImpl<OtaManageApplyEOMap
conSb.append(user.getUsername()).append(" : "); conSb.append(user.getUsername()).append(" : ");
conSbEn.append(user.getUsername()).append(" : "); conSbEn.append(user.getUsername()).append(" : ");
if (StringUtils.isNotEmpty(oma.getProjectVersion())) { if (StringUtils.isNotEmpty(oma.getProjectVersion())) {
conSb.append("‘项目版本‘ 由 ‘空‘").append(" 改为 ‘").append(oma.getProjectVersionText()).append("‘."); conSb.append("‘项目版本‘ 由 ‘空‘").append(" 改为 ‘").append(proNameMap.get(oma.getProjectVersion())).append("‘.");
conSbEn.append("‘Project Version‘ change from ‘null‘").append(" to ‘").append(oma.getProjectVersionText()).append("‘."); conSbEn.append("‘Project Version‘ change from ‘null‘").append(" to ‘").append(proNameMap.get(oma.getProjectVersion())).append("‘.");
} }
if (StringUtils.isNotEmpty(oma.getAttestationSchedule())) { if (StringUtils.isNotEmpty(oma.getAttestationSchedule())) {
conSb.append("‘认证进度‘ 由 ‘空‘").append(" 改为 ‘").append(CertificationProgressEnum.getByValue(oma.getAttestationSchedule()).getName()).append("‘."); conSb.append("‘认证进度‘ 由 ‘空‘").append(" 改为 ‘").append(CertificationProgressEnum.getByValue(oma.getAttestationSchedule()).getName()).append("‘.");
@@ -1221,48 +1236,67 @@ public class OtaManageApplyEOServiceImpl extends ServiceImpl<OtaManageApplyEOMap
@Override @Override
public List<String> updateVdrBatch(List<OtaManageApplyEO> list, String projectVersion, String attestationSchedule, String remark, String cut) { public List<String> updateVdrBatch(List<OtaManageApplyEO> list, String projectVersion, String attestationSchedule, String remark, String cut) {
ProjectLibraryBase plb = projectLibraryBaseService.selectById(projectVersion); ProjectLibraryBase plb = projectLibraryBaseService.selectById(projectVersion);
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
//历史记录
List<OtaManageHistory> hisList = new ArrayList<>();
List<String> msgList = new ArrayList<>(); List<String> msgList = new ArrayList<>();
List<OtaManageApplyEO> changeList = new ArrayList<>();
boolean isStudio = isStudio();
boolean isOtaManager = isOtaManager();
for (OtaManageApplyEO oma : list) { for (OtaManageApplyEO oma : list) {
StringBuilder conOtaCn = new StringBuilder();
StringBuilder conOtaEn = new StringBuilder();
conOtaCn.append(user.getUsername() + " 批量编辑了 VDR: ").append(oma.getVdr());
conOtaEn.append(user.getUsername() + " edited VDR: ").append(oma.getVdr());
boolean isChanged = false; boolean isChanged = false;
if (isStudio() && (StringUtils.isEmpty(oma.getMatchStatus()) || oma.getMatchStatus().equals(OtaStatusEnum.TO_BE_MATCHED.getKey()))) { if (StringUtils.isNotEmpty(projectVersion)) {
if (StringUtils.isNotEmpty(projectVersion)) { if (isStudio) {
isChanged = true; if (StringUtils.isEmpty(oma.getMatchStatus())
oma.setProjectVersion(projectVersion); || oma.getMatchStatus().equals(OtaStatusEnum.TO_BE_MATCHED.getKey())
conOtaCn.append(" 修改了 ").append("项目版本 ").append(" 改为 ").append(plb.getShowName()); || oma.getMatchStatus().equals(OtaStatusEnum.REJECTED.getKey())) {
conOtaEn.append(" modified ").append("Project Version change to ").append(plb.getShowName()); isChanged = true;
} oma.setProjectVersion(projectVersion);
if (StringUtils.isNotEmpty(attestationSchedule)) { } else {
isChanged = true; if (CutEnum.CN.getValue().equals(cut)) {
oma.setAttestationSchedule(attestationSchedule); msgList.add("VDR:" + oma.getVdr() + " 状态必须为" + OtaStatusEnum.TO_BE_MATCHED.getNameCN() + " 或 " + OtaStatusEnum.REJECTED.getNameCN() + "!");
conOtaCn.append(" 修改了 ").append("认证进度 ").append(" 改为 ").append(CertificationProgressEnum.getByValue(attestationSchedule).getName()); } else {
conOtaEn.append(" modified ").append("Homologation Progress change to ").append(CertificationProgressEnum.getByValue(attestationSchedule).getValue()); msgList.add("VDR:" + oma.getVdr() + " The state must be" + OtaStatusEnum.TO_BE_MATCHED.getNameEN() + " or " + OtaStatusEnum.REJECTED.getNameEN() + "!");
}
}
} else {
if (CutEnum.CN.getValue().equals(cut)) {
msgList.add("VDR:" + oma.getVdr() + " 只有Studio角色可以编辑项目版本!");
} else {
msgList.add("VDR:" + oma.getVdr() + " Only Studio roles can edit Project Version!");
}
} }
} }
if (isStudio() || isOtaManager()) { if (StringUtils.isNotEmpty(attestationSchedule)) {
if (StringUtils.isNotEmpty(remark)) { if (isStudio) {
isChanged = true; if (StringUtils.isEmpty(oma.getMatchStatus())
oma.setRemark(remark); || oma.getMatchStatus().equals(OtaStatusEnum.TO_BE_MATCHED.getKey())
conOtaCn.append(" 修改了 ").append("备注 ").append(" 改为 ").append(remark); || oma.getMatchStatus().equals(OtaStatusEnum.REJECTED.getKey())) {
conOtaEn.append(" modified ").append("Remark change to ").append(remark); isChanged = true;
oma.setAttestationSchedule(attestationSchedule);
} else {
if (CutEnum.CN.getValue().equals(cut)) {
msgList.add("VDR:" + oma.getVdr() + " 状态必须为" + OtaStatusEnum.TO_BE_MATCHED.getNameCN() + " 或 " + OtaStatusEnum.REJECTED.getNameCN() + "!");
} else {
msgList.add("VDR:" + oma.getVdr() + " The state must be" + OtaStatusEnum.TO_BE_MATCHED.getNameEN() + " or " + OtaStatusEnum.REJECTED.getNameEN() + "!");
}
}
} else {
if (CutEnum.CN.getValue().equals(cut)) {
msgList.add("VDR:" + oma.getVdr() + " 只有Studio角色可以编辑认证进度!");
} else {
msgList.add("VDR:" + oma.getVdr() + " Only Studio roles can edit Homologation Progress!");
}
} }
} }
if (StringUtils.isNotEmpty(remark) && !remark.equals("--")) {
isChanged = true;
oma.setRemark(remark);
}
if (isChanged) { if (isChanged) {
OtaManageHistory his = new OtaManageHistory(); changeList.add(oma);
his.setApplyId(oma.getId());
his.setContentCn(conOtaCn.toString());
his.setContentEn(conOtaEn.toString());
hisList.add(his);
} }
} }
this.saveOrUpdateBatch(list); if (CollectionUtils.isNotEmpty(changeList)) {
otaManageHistoryService.saveBatch(hisList); this.temporarySave(changeList, cut);
}
return msgList; return msgList;
} }