|
@@ -20,9 +20,11 @@ import org.springframework.util.MultiValueMap;
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
|
|
+import java.util.Comparator;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.concurrent.CompletableFuture;
|
|
import java.util.concurrent.CompletableFuture;
|
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
@Component
|
|
@Component
|
|
|
public class CrmRest {
|
|
public class CrmRest {
|
|
@@ -115,22 +117,36 @@ public class CrmRest {
|
|
|
//todo 异步逻辑处理
|
|
//todo 异步逻辑处理
|
|
|
// CompletableFuture.runAsync(()->{
|
|
// CompletableFuture.runAsync(()->{
|
|
|
//先删除
|
|
//先删除
|
|
|
- crmNoticeMapper.deleteByMap(ImmutableMap.of("work_code",workcode));
|
|
|
|
|
- //再添加到消息表里面
|
|
|
|
|
- crmNotices.forEach(e ->{
|
|
|
|
|
- CrmNoticeDO crmNoticeDO = new CrmNoticeDO();
|
|
|
|
|
- CrmNoticeDetail notice = e.getNotice();
|
|
|
|
|
- BeanUtils.copyProperties(notice,crmNoticeDO);
|
|
|
|
|
- crmNoticeDO.setContentMajor(e.getContent());
|
|
|
|
|
- crmNoticeDO.setDeleted(false);
|
|
|
|
|
- crmNoticeDO.setWorkCode(workcode);
|
|
|
|
|
- crmNoticeMapper.insert(crmNoticeDO);
|
|
|
|
|
- });
|
|
|
|
|
-// });
|
|
|
|
|
-
|
|
|
|
|
|
|
+ //crmNoticeMapper.deleteByMap(ImmutableMap.of("work_code",workcode));
|
|
|
|
|
+ //取最近的那条纪录
|
|
|
|
|
+ CrmNoticeDO crmNoticeDO1 = crmNoticeMapper.selectList("work_code", workcode).stream()
|
|
|
|
|
+ .max(Comparator.comparing(CrmNoticeDO::getCreatedAt))
|
|
|
|
|
+ .orElse(null);
|
|
|
|
|
+ if (crmNoticeDO1 == null) {
|
|
|
|
|
+ insertBatchNotice(crmNotices, workcode);
|
|
|
|
|
+ }else {
|
|
|
|
|
+ List<CrmNotice> collect = crmNotices.stream().filter(e -> {
|
|
|
|
|
+ CrmNoticeDetail notice = e.getNotice();
|
|
|
|
|
+ if (notice == null) {return false;}
|
|
|
|
|
+ return notice.getStatus() != 1&¬ice.getCreatedAt()>Long.parseLong(crmNoticeDO1.getCreatedAt());
|
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
|
+ insertBatchNotice(collect, workcode);
|
|
|
|
|
+ }
|
|
|
return crmNotices;
|
|
return crmNotices;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public void insertBatchNotice(List<CrmNotice> crmNotices, String workcode) {
|
|
|
|
|
+ crmNotices.forEach(e ->{
|
|
|
|
|
+ CrmNoticeDO crmNoticeDO = new CrmNoticeDO();
|
|
|
|
|
+ CrmNoticeDetail notice = e.getNotice();
|
|
|
|
|
+ BeanUtils.copyProperties(notice,crmNoticeDO);
|
|
|
|
|
+ crmNoticeDO.setContentMajor(e.getContent());
|
|
|
|
|
+ crmNoticeDO.setDeleted(false);
|
|
|
|
|
+ crmNoticeDO.setWorkCode(workcode);
|
|
|
|
|
+ crmNoticeMapper.insert(crmNoticeDO);
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Data
|
|
@Data
|
|
|
static class CrmUser{
|
|
static class CrmUser{
|
|
|
private String id;
|
|
private String id;
|