修改OTA定时任务
This commit is contained in:
+185
-1
@@ -1,27 +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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
+2
@@ -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();
|
||||
|
||||
}
|
||||
|
||||
+2
@@ -14,4 +14,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
*/
|
||||
public interface OtaManageReceiveNsdpMapper extends BaseMapper<OtaManageReceiveNsdp> {
|
||||
|
||||
List<OtaManageReceiveNsdp> getOtaManageReceiveNsdpSync();
|
||||
|
||||
}
|
||||
|
||||
+5
@@ -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>
|
||||
+3
@@ -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>
|
||||
+3
@@ -58,4 +58,7 @@ public interface IOtaManageReceiveNsdpService extends IService<OtaManageReceiveN
|
||||
* @return
|
||||
*/
|
||||
List<OtaManageReceiveNsdp> queryList();
|
||||
|
||||
|
||||
List<OtaManageReceiveNsdp> getOtaManageReceiveNsdpSync();
|
||||
}
|
||||
|
||||
+4
@@ -63,4 +63,8 @@ public interface IOtaManageReceiveService extends IService<OtaManageReceive> {
|
||||
List<OtaManageReceive> getReceiveByVdr(List<String> vdrList);
|
||||
|
||||
List<OtaManageReceive> getReceiveByplanned(String plannedBpLaunchBatch);
|
||||
|
||||
List<OtaManageReceive> getReceiveSync();
|
||||
|
||||
|
||||
}
|
||||
|
||||
+5
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
+6
@@ -99,4 +99,10 @@ public class OtaManageReceiveServiceImpl extends ServiceImpl<OtaManageReceiveMap
|
||||
queryWrapper.lambda().eq(OtaManageReceive::getPlannedBpLaunchBatch, plannedBpLaunchBatch);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OtaManageReceive> getReceiveSync() {
|
||||
return this.getBaseMapper().getReceiveSync();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user