Merge remote-tracking branch 'origin/dev_20230808_OTA' into dev_20230808_OTA

This commit is contained in:
zyx.net
2023-08-23 14:29:04 +08:00
10 changed files with 347 additions and 6 deletions
@@ -0,0 +1,211 @@
package com.jero.modules.ota.job;
import com.jero.modules.ota.entity.OtaManageReceive;
import com.jero.modules.ota.entity.OtaManageReceiveNsdp;
import com.jero.modules.ota.service.IOtaManageReceiveNsdpService;
import com.jero.modules.ota.service.IOtaManageReceiveService;
import com.jero.modules.system.util.StringUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
@Service
public class OtaDataUpdate implements Job {
@Autowired
private IOtaManageReceiveService otaManageReceiveService;
@Autowired
private IOtaManageReceiveNsdpService otaManageReceiveNsdpService;
private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
/**
* OTA数据更新
*
* @param jobExecutionContext
* @throws JobExecutionException
*/
@Override
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
List<OtaManageReceive> omrSyncList = otaManageReceiveService.getReceiveSync();
List<OtaManageReceive> omrList = otaManageReceiveService.queryList();
List<OtaManageReceive> addList = new ArrayList<>();
List<String> delList = new ArrayList<>();
List<OtaManageReceive> updateList = new ArrayList<>();
for (OtaManageReceive omr : omrList) {
boolean delFlag = true;
for (OtaManageReceive omrSync : omrSyncList) {
if (omr.getId().equals(omrSync.getId())) {
delFlag = false;
if (!compareReceive(omr, omrSync)) {
updateList.add(omrSync);
}
}
}
if (delFlag) {
//同步数据中被删除
delList.add(omr.getId());
}
}
for (OtaManageReceive omrSync : omrSyncList) {
boolean addFlag = true;
for (OtaManageReceive omr : omrList) {
if (omr.getId().equals(omrSync.getId())) {
addFlag = false;
}
}
if (addFlag) {
//同步数据中新增
addList.add(omrSync);
}
}
if (CollectionUtils.isNotEmpty(addList)) {
otaManageReceiveService.saveBatch(addList);
}
if (CollectionUtils.isNotEmpty(addList)) {
otaManageReceiveService.deleteByIds(delList);
}
if (CollectionUtils.isNotEmpty(updateList)) {
otaManageReceiveService.updateBatchById(updateList);
}
List<OtaManageReceiveNsdp> omrnSyncList = otaManageReceiveNsdpService.getOtaManageReceiveNsdpSync();
List<OtaManageReceiveNsdp> omrnList = otaManageReceiveNsdpService.queryList();
List<OtaManageReceiveNsdp> addNsdpList = new ArrayList<>();
List<String> delNsdpList = new ArrayList<>();
List<OtaManageReceiveNsdp> updateNsdpList = new ArrayList<>();
for (OtaManageReceiveNsdp omrn : omrnList) {
boolean delFlag = true;
for (OtaManageReceiveNsdp omrnSync : omrnSyncList) {
if (omrn.getId().equals(omrnSync.getId())) {
delFlag = false;
if (!compareReceive(omrn, omrnSync)) {
updateNsdpList.add(omrnSync);
}
}
}
if (delFlag) {
//同步数据中被删除
delNsdpList.add(omrn.getId());
}
}
Map<String, Date> releaceDateMap = new HashMap<>();
Date today = new Date();
for (OtaManageReceiveNsdp omrnSync : omrnSyncList) {
boolean addFlag = true;
for (OtaManageReceiveNsdp omrn : omrnList) {
if (omrn.getId().equals(omrnSync.getId())) {
addFlag = false;
}
}
if (addFlag) {
//同步数据中新增
addNsdpList.add(omrnSync);
}
//找到最快来临的发布时间
Date releaceDate = releaceDateMap.get(omrnSync.getReleaseName());
try {
Date syncDate = sdf.parse(omrnSync.getReleaseDate());
if (null == releaceDate) {
releaceDateMap.put(omrnSync.getReleaseName(), syncDate);
} else {
if (syncDate.after(today) && syncDate.before(releaceDate)) {
releaceDateMap.put(omrnSync.getReleaseName(), syncDate);
}
}
} catch (ParseException e) {
e.printStackTrace();
}
}
if (CollectionUtils.isNotEmpty(addNsdpList)) {
otaManageReceiveNsdpService.saveBatch(addNsdpList);
}
if (CollectionUtils.isNotEmpty(delNsdpList)) {
otaManageReceiveNsdpService.deleteByIds(delNsdpList);
}
if (CollectionUtils.isNotEmpty(updateNsdpList)) {
otaManageReceiveNsdpService.updateBatchById(updateNsdpList);
}
List<OtaManageReceive> dateUpdateList = new ArrayList<>();
List<OtaManageReceive> omrListForDate = otaManageReceiveService.queryList();
for (OtaManageReceive omr : omrListForDate) {
if(releaceDateMap.containsKey(omr.getPlannedBpLaunchBatch())){
omr.setReleaseDate(sdf.format(releaceDateMap.get(omr.getPlannedBpLaunchBatch())));
dateUpdateList.add(omr);
}
}
if (CollectionUtils.isNotEmpty(dateUpdateList)) {
otaManageReceiveService.updateBatchById(dateUpdateList);
}
}
private boolean compareReceive(OtaManageReceiveNsdp omrn, OtaManageReceiveNsdp omrnSync) {
if (!StringUtils.equals(omrn.getPlatformName(), omrnSync.getPlatformName())) {
return false;
}
if (!StringUtils.equals(omrn.getReleaseName(), omrnSync.getReleaseName())) {
return false;
}
if (!StringUtils.equals(omrn.getReleaseType(), omrnSync.getReleaseType())) {
return false;
}
if (!StringUtils.equals(omrn.getDateName(), omrnSync.getDateName())) {
return false;
}
if (!StringUtils.equals(omrn.getReleaseDate(), omrnSync.getReleaseDate())) {
return false;
}
return true;
}
private boolean compareReceive(OtaManageReceive omr, OtaManageReceive omrSync) {
if (!StringUtils.equals(omr.getPlannedBpLaunchBatch(), omrSync.getPlannedBpLaunchBatch())) {
return false;
}
if (!StringUtils.equals(omr.getSummary(), omrSync.getSummary())) {
return false;
}
if (!StringUtils.equals(omr.getStatus(), omrSync.getStatus())) {
return false;
}
if (!StringUtils.equals(omr.getHomologationImpact(), omrSync.getHomologationImpact())) {
return false;
}
if (!StringUtils.equals(omr.getHomologation(), omrSync.getHomologation())) {
return false;
}
if (!StringUtils.equals(omr.getImpactCnHomo(), omrSync.getImpactCnHomo())) {
return false;
}
if (!StringUtils.equals(omr.getImpactEuHomo(), omrSync.getImpactEuHomo())) {
return false;
}
if (!StringUtils.equals(omr.getMasterDomain(), omrSync.getMasterDomain())) {
return false;
}
if (!StringUtils.equals(omr.getAppliedVehicleProject(), omrSync.getAppliedVehicleProject())) {
return false;
}
return true;
}
}
@@ -15,4 +15,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
public interface OtaManageReceiveMapper extends BaseMapper<OtaManageReceive> {
List<OtaManageReceive> getReceiveByVdr(@Param("vdrList") List<String> vdrList);
List<OtaManageReceive> getReceiveSync();
}
@@ -14,4 +14,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
*/
public interface OtaManageReceiveNsdpMapper extends BaseMapper<OtaManageReceiveNsdp> {
List<OtaManageReceiveNsdp> getOtaManageReceiveNsdpSync();
}
@@ -27,4 +27,9 @@
#{item}
</foreach>
</select>
<select id="getReceiveSync" resultType="com.jero.modules.ota.entity.OtaManageReceive">
select * from ota_manage_receive_sync
</select>
</mapper>
@@ -15,4 +15,7 @@
<result column="release_date" property="releaseDate" />
<result column="created_at" property="createdAt" />
</resultMap>
<select id="getOtaManageReceiveNsdpSync" resultType="com.jero.modules.ota.entity.OtaManageReceive">
select * from ota_manage_receive_nsdp_sync
</select>
</mapper>
@@ -58,4 +58,7 @@ public interface IOtaManageReceiveNsdpService extends IService<OtaManageReceiveN
* @return
*/
List<OtaManageReceiveNsdp> queryList();
List<OtaManageReceiveNsdp> getOtaManageReceiveNsdpSync();
}
@@ -61,4 +61,10 @@ public interface IOtaManageReceiveService extends IService<OtaManageReceive> {
List<OtaManageReceive> queryList();
List<OtaManageReceive> getReceiveByVdr(List<String> vdrList);
List<OtaManageReceive> getReceiveByplanned(String plannedBpLaunchBatch);
List<OtaManageReceive> getReceiveSync();
}
@@ -9,6 +9,7 @@ import com.jero.common.util.oConvertUtils;
import com.jero.modules.cert.template.entity.CertCategoryParamsInfoEO;
import com.jero.modules.dummy.enums.OrderEnum;
import com.jero.modules.ota.entity.OtaManageApplyEO;
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;
@@ -17,6 +18,7 @@ import com.jero.modules.ota.enums.OtaStatusEnum;
import com.jero.modules.ota.mapper.OtaManageApplyEOMapper;
import com.jero.modules.ota.service.IOtaManageApplyEOService;
import com.jero.modules.ota.service.IOtaManageHistoryService;
import com.jero.modules.ota.service.IOtaManagePermissionService;
import com.jero.modules.ota.vo.AllCarExportCnVO;
import com.jero.modules.ota.vo.AllCarExportEnVO;
import com.jero.modules.ota.vo.OneCarExportCnVO;
@@ -83,6 +85,10 @@ public class OtaManageApplyEOServiceImpl extends ServiceImpl<OtaManageApplyEOMap
private IOtaManageHistoryService otaManageHistoryService;
@Autowired
private IOtaManageReceiveService otaManageReceiveService;
@Autowired
private IOtaManagePermissionService otaManagePermissionService;
@Value(value = "${jero.path.upload}")
private String upLoadPath;
@@ -864,7 +870,96 @@ public class OtaManageApplyEOServiceImpl extends ServiceImpl<OtaManageApplyEOMap
*/
@Override
public void issueNotice(String id) {
if (StringUtils.isNotEmpty(id)) {
//根据版本查出所有vdr
List<OtaManageReceive> omrList = otaManageReceiveService.getReceiveByplanned(id);
List<String> appliedVehicleProjectList = omrList.stream()
.filter(e -> StringUtils.isNotBlank(e.getAppliedVehicleProject()))
.map(OtaManageReceive::getAppliedVehicleProject).distinct().collect(Collectors.toList());
Map<String, Set> appMap = new HashMap<>();
for (String appStr : appliedVehicleProjectList) {
if (StringUtils.isNotEmpty(appStr)) {
String[] appStrs = appStr.split(",");
for (String str : appStrs) {
String[] s = str.split(" ");
if (appStrs.length == 1) {
if (!appMap.containsKey(s[0])) {
appMap.put(s[0], null);
}
} else if (s.length == 2) {
String projectName = s[0].toUpperCase(Locale.ROOT);
Set appSet = appMap.get(projectName);
if (ObjectUtils.isEmpty(appSet)) {
appSet = new HashSet();
}
if(s[1].equals("CN")){
appSet.add("China");
}else if(s[1].equals("RHD")){
appSet.add("UK");
}else{
appSet.add(s[1]);
}
appMap.put(projectName, appSet);
} else if (s.length == 3) {
String projectName = s[0].toUpperCase(Locale.ROOT);
Set appSet = appMap.get(projectName);
if (ObjectUtils.isEmpty(appSet)) {
appSet = new HashSet();
}
if(s[2].equals("CN")){
appSet.add("China");
}else if(s[2].equals("RHD")){
appSet.add("UK");
}else{
appSet.add(s[2]);
}
appMap.put(projectName, appSet);
}
}
}
}
//查询所有NT2平台的项目
ProjectLibraryBase plbSearch = new ProjectLibraryBase();
plbSearch.setDigitalPlatform("NT2");
List<ProjectLibraryBase> plbList = projectLibraryBaseService.getList(plbSearch);
//存储符合条件的项目中Studio的用户ID
Set<String> matchStudioSet = new HashSet();
for (ProjectLibraryBase plb : plbList) {
boolean flag = false;
if (appMap.containsKey("All")) {
matchStudioSet.add(plb.getStudioEngineer());
continue;
}
String targetMarket = plb.getTargetMarket();
String projectName = plb.getProjectName().toUpperCase(Locale.ROOT);
String[] targetMarkets = targetMarket.split(",");
for (String tm : targetMarkets) {
if ((appMap.containsKey("CN") && tm.equals("China"))
|| (appMap.containsKey("EU") && tm.equals("EU"))
|| (appMap.containsKey("RHD") && tm.equals("UK"))) {
//三个ALL的市场类型
matchStudioSet.add(plb.getStudioEngineer());
continue;
}
if(appMap.containsKey(projectName)){
Set appSet = appMap.get(projectName);
if(appSet.contains(tm)){
matchStudioSet.add(plb.getStudioEngineer());
continue;
}
}
}
}
//TODO 给studio发消息
List<OtaManagePermission> ompList = new ArrayList<>();
for (String studioId : matchStudioSet) {
OtaManagePermission omp = new OtaManagePermission();
omp.setApplyId(id);
omp.setUserId(studioId);
ompList.add(omp);
}
otaManagePermissionService.saveBatch(ompList);
}
}
@@ -1032,7 +1127,6 @@ public class OtaManageApplyEOServiceImpl extends ServiceImpl<OtaManageApplyEOMap
int toBeApproved = 0;//待审批
int locked = 0;//锁定
int rejected = 0;//退回
int toBeRematched = 0;//待重新匹配
//认证进度
int notStart = 0;//未开始
int inProgress = 0;//进行中
@@ -1051,8 +1145,6 @@ public class OtaManageApplyEOServiceImpl extends ServiceImpl<OtaManageApplyEOMap
locked++;
} else if (oma.getMatchStatus().equals(OtaStatusEnum.REJECTED.getKey())) {
rejected++;
} else if (oma.getMatchStatus().equals(OtaStatusEnum.TO_BE_REMATCHED.getKey())) {
toBeRematched++;
} else {
toBeMatched++;
}
@@ -1082,7 +1174,6 @@ public class OtaManageApplyEOServiceImpl extends ServiceImpl<OtaManageApplyEOMap
matchStatusMapList.add(wrapStatMap("matchStatus", "matchStatusCount", OtaStatusEnum.TO_BE_APPROVED.getKey(), toBeApproved));
matchStatusMapList.add(wrapStatMap("matchStatus", "matchStatusCount", OtaStatusEnum.LOCKED.getKey(), locked));
matchStatusMapList.add(wrapStatMap("matchStatus", "matchStatusCount", OtaStatusEnum.REJECTED.getKey(), rejected));
matchStatusMapList.add(wrapStatMap("matchStatus", "matchStatusCount", OtaStatusEnum.TO_BE_REMATCHED.getKey(), toBeRematched));
statisticalMap.put("matchStatusMapList", matchStatusMapList);
Map<String, Object> matchStatusMap = new HashMap<>();
@@ -1090,7 +1181,6 @@ public class OtaManageApplyEOServiceImpl extends ServiceImpl<OtaManageApplyEOMap
matchStatusMap.put(OtaStatusEnum.TO_BE_APPROVED.getKey(),toBeApproved);
matchStatusMap.put(OtaStatusEnum.LOCKED.getKey(),locked);
matchStatusMap.put(OtaStatusEnum.REJECTED.getKey(),rejected);
matchStatusMap.put(OtaStatusEnum.TO_BE_REMATCHED.getKey(),toBeRematched);
statisticalMap.put("matchStatusMap", matchStatusMap);
List<Map<String, Object>> attestationScheduleMapList = new ArrayList<>();
@@ -86,4 +86,9 @@ public class OtaManageReceiveNsdpServiceImpl extends ServiceImpl<OtaManageReceiv
public List<OtaManageReceiveNsdp> queryList() {
return list();
}
@Override
public List<OtaManageReceiveNsdp> getOtaManageReceiveNsdpSync() {
return this.getBaseMapper().getOtaManageReceiveNsdpSync();
}
}
@@ -1,5 +1,6 @@
package com.jero.modules.ota.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jero.modules.ota.entity.OtaManageReceive;
import com.jero.modules.ota.mapper.OtaManageReceiveMapper;
import com.jero.modules.ota.service.IOtaManageReceiveService;
@@ -91,4 +92,17 @@ public class OtaManageReceiveServiceImpl extends ServiceImpl<OtaManageReceiveMap
public List<OtaManageReceive> getReceiveByVdr(List<String> vdrList) {
return this.getBaseMapper().getReceiveByVdr(vdrList);
}
@Override
public List<OtaManageReceive> getReceiveByplanned(String plannedBpLaunchBatch) {
QueryWrapper<OtaManageReceive> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(OtaManageReceive::getPlannedBpLaunchBatch, plannedBpLaunchBatch);
return this.list(queryWrapper);
}
@Override
public List<OtaManageReceive> getReceiveSync() {
return this.getBaseMapper().getReceiveSync();
}
}