|
|
|
@ -2,6 +2,7 @@ package com.logpm.basicdata.job;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
|
|
import cn.hutool.core.convert.Convert; |
|
|
|
|
import cn.hutool.core.date.DateUtil; |
|
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
|
import com.logpm.basicdata.entity.BasicdataPriceEntity; |
|
|
|
@ -15,9 +16,13 @@ import lombok.AllArgsConstructor;
|
|
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.Date; |
|
|
|
|
import java.util.HashMap; |
|
|
|
|
import java.util.HashSet; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Map; |
|
|
|
|
import java.util.Set; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @author zhaoqiaobo |
|
|
|
@ -70,5 +75,46 @@ public class BasicdataPriceJob {
|
|
|
|
|
return ReturnT.SUCCESS; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 定时维护价格的生效状态 |
|
|
|
|
* 每天凌晨定时维护一次 |
|
|
|
|
* |
|
|
|
|
* @param param |
|
|
|
|
* @return |
|
|
|
|
* @throws Exception |
|
|
|
|
*/ |
|
|
|
|
@XxlJob("changePriceEffectiveStatus") |
|
|
|
|
public ReturnT<String> changePriceEffectiveStatus(String param) throws Exception { |
|
|
|
|
// 未生效转生效的价格
|
|
|
|
|
Set<String> effectiveSet = new HashSet<>(); |
|
|
|
|
List<BasicdataPriceEntity> list = priceService.list(Wrappers.<BasicdataPriceEntity>lambdaQuery().in(BasicdataPriceEntity::getEffectiveStatus, -1, 0)); |
|
|
|
|
if (CollUtil.isNotEmpty(list)) { |
|
|
|
|
List<BasicdataPriceEntity> collect = list.stream().filter(item -> item.getEffectiveStatus() == -1 && StrUtil.equals(DateUtil.formatDate(item.getEffectiveTime()), DateUtil.formatDate(DateUtil.beginOfDay(new Date())))).collect(Collectors.toList()); |
|
|
|
|
if (CollUtil.isNotEmpty(collect)) { |
|
|
|
|
Set<Long> updateSet = new HashSet<>(); |
|
|
|
|
for (BasicdataPriceEntity basicdataPriceEntity : collect) { |
|
|
|
|
effectiveSet.add(Convert.toStr(basicdataPriceEntity.getClientId()) + Convert.toStr(basicdataPriceEntity.getBrandId())); |
|
|
|
|
updateSet.add(basicdataPriceEntity.getId()); |
|
|
|
|
} |
|
|
|
|
if (CollUtil.isNotEmpty(updateSet)) { |
|
|
|
|
priceService.update(Wrappers.<BasicdataPriceEntity>lambdaUpdate().set(BasicdataPriceEntity::getEffectiveStatus, 0).in(BasicdataPriceEntity::getId, updateSet)); |
|
|
|
|
} |
|
|
|
|
List<BasicdataPriceEntity> collect1 = list.stream().filter(item -> item.getEffectiveStatus() == 0).collect(Collectors.toList()); |
|
|
|
|
if (CollUtil.isNotEmpty(collect1)) { |
|
|
|
|
Set<Long> updateSet1 = new HashSet<>(); |
|
|
|
|
for (BasicdataPriceEntity basicdataPriceEntity : collect1) { |
|
|
|
|
if(CollUtil.contains(effectiveSet,Convert.toStr(basicdataPriceEntity.getClientId()) + Convert.toStr(basicdataPriceEntity.getBrandId()))){ |
|
|
|
|
updateSet1.add(basicdataPriceEntity.getId()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if(CollUtil.isNotEmpty(updateSet1)){ |
|
|
|
|
priceService.update(Wrappers.<BasicdataPriceEntity>lambdaUpdate().set(BasicdataPriceEntity::getEffectiveStatus, 1).in(BasicdataPriceEntity::getId, updateSet1)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return ReturnT.SUCCESS; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|