|
|
@@ -2,6 +2,7 @@ package com.ydtech.modules.order.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.ydtech.constants.RabbitMqEnum;
|
|
|
import com.ydtech.constants.enums.dict.InsOrderStatusEnum;
|
|
|
import com.ydtech.modules.admin.utils.SliceUpDateUtil;
|
|
|
import com.ydtech.modules.order.dao.InsOrderPushMsgMapper;
|
|
|
@@ -11,21 +12,25 @@ import com.ydtech.modules.order.entity.InsOrders;
|
|
|
import com.ydtech.modules.order.entity.dto.InsTaskImagesDto;
|
|
|
import com.ydtech.modules.order.entity.po.InsOrderPushMsg;
|
|
|
import com.ydtech.modules.order.entity.vo.PushDataVo;
|
|
|
-import com.ydtech.modules.order.orderThread.OrderFailRunnableThread;
|
|
|
-import com.ydtech.modules.order.orderThread.OrderRunnableThread;
|
|
|
-import com.ydtech.modules.order.orderThread.OrderSignRunnableThread;
|
|
|
import com.ydtech.modules.order.service.InsAreaCompanyService;
|
|
|
import com.ydtech.modules.order.service.InsOrderPushMsgService;
|
|
|
import com.ydtech.modules.order.service.InsOrdersService;
|
|
|
import com.ydtech.utils.OrderUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.amqp.core.Message;
|
|
|
+import org.springframework.amqp.core.MessageProperties;
|
|
|
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
+import java.util.UUID;
|
|
|
+
|
|
|
+import static org.springframework.amqp.core.MessageProperties.CONTENT_TYPE_TEXT_PLAIN;
|
|
|
|
|
|
/**
|
|
|
* @author Administrator
|
|
|
@@ -53,6 +58,9 @@ public class InsOrderPushMsgServiceImpl extends ServiceImpl<InsOrderPushMsgMappe
|
|
|
@Autowired
|
|
|
private RabbitTemplate rabbitTemplate;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private InsOrderPushMsgService insOrderPushMsgService;
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* @version
|
|
|
@@ -61,25 +69,29 @@ public class InsOrderPushMsgServiceImpl extends ServiceImpl<InsOrderPushMsgMappe
|
|
|
* @Description: 推送历史的订单信息
|
|
|
*/
|
|
|
@Override
|
|
|
- public void getPushInsAreaCompanyList() {
|
|
|
- List<String> dateList = insOrderPushMsgMapper.getPushInsAreaCompanyDateList();
|
|
|
- // List<String> dateList =new ArrayList<String>();
|
|
|
- // dateList.add("2024-10");
|
|
|
- if(dateList!=null && !dateList.isEmpty()){
|
|
|
- //启动线程池
|
|
|
- dateList.forEach(item ->{
|
|
|
- String benginTime = SliceUpDateUtil.getStartOfMonth(Integer.parseInt(item.split("-")[0]), Integer.parseInt(item.split("-")[1]));
|
|
|
- String endTime = SliceUpDateUtil.getEndOfMonth(Integer.parseInt(item.split("-")[0]), Integer.parseInt(item.split("-")[1]));
|
|
|
- List<String> orderList = insOrderPushMsgMapper.getPushInsAreaCompanyList(benginTime,endTime);
|
|
|
- ArrayList<String> pushDataList =new ArrayList<String>();
|
|
|
- if(orderList!=null && !orderList.isEmpty()){
|
|
|
- orderList.forEach(orderId ->{
|
|
|
- pushDataList.add(getPushDataJsonString(orderId));
|
|
|
- });
|
|
|
- }
|
|
|
- if(pushDataList!=null && !pushDataList.isEmpty()){
|
|
|
- Thread thread = new Thread(new OrderRunnableThread(rabbitTemplate, pushDataList,this));
|
|
|
- thread.start();
|
|
|
+ public void getPushInsAreaCompanyList(String month) {
|
|
|
+ String benginTime = SliceUpDateUtil.getStartOfMonth(Integer.parseInt(month.split("-")[0]), Integer.parseInt(month.split("-")[1]));
|
|
|
+ String endTime = SliceUpDateUtil.getEndOfMonth(Integer.parseInt(month.split("-")[0]), Integer.parseInt(month.split("-")[1]));
|
|
|
+ List<String> orderList = insOrderPushMsgMapper.getPushInsAreaCompanyList(benginTime,endTime);
|
|
|
+ ArrayList<String> pushDataList =new ArrayList<String>();
|
|
|
+ if(orderList!=null && !orderList.isEmpty()){
|
|
|
+ orderList.forEach(orderId ->{
|
|
|
+ PushDataVo pushDataVo = getPushData(orderId);
|
|
|
+ String items = JSONObject.toJSONString(pushDataVo);
|
|
|
+ MessageProperties messageProperties = new MessageProperties();
|
|
|
+ messageProperties.setMessageId(UUID.randomUUID().toString());
|
|
|
+ messageProperties.setContentType(CONTENT_TYPE_TEXT_PLAIN);
|
|
|
+ messageProperties.setContentEncoding("UTF-8");
|
|
|
+ Message message_cj = new Message(items.getBytes(StandardCharsets.UTF_8), messageProperties);
|
|
|
+ //推送
|
|
|
+ InsOrderPushMsg insOrderPushMsg = new InsOrderPushMsg(null, pushDataVo.getInsAreaCompany().getId(), "0", new Date(), pushDataVo.toString());
|
|
|
+ try{
|
|
|
+ //更新狀態
|
|
|
+ insOrderPushMsgService.save(insOrderPushMsg);
|
|
|
+ this.rabbitTemplate.convertAndSend(RabbitMqEnum.ORDER_EXCHANGE.getCode(), RabbitMqEnum.ORDER_ROUTINGKEY.getCode(), message_cj);
|
|
|
+ Thread.sleep(1500);
|
|
|
+ }catch(Exception e){
|
|
|
+ e.getStackTrace();
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
@@ -98,13 +110,25 @@ public class InsOrderPushMsgServiceImpl extends ServiceImpl<InsOrderPushMsgMappe
|
|
|
if(orderList!=null && !orderList.isEmpty()){
|
|
|
//通过
|
|
|
orderList.forEach(orderId ->{
|
|
|
- pushDataList.add(getPushDataJsonString(orderId));
|
|
|
+ PushDataVo pushDataVo = getPushData(orderId);
|
|
|
+ String item = JSONObject.toJSONString(pushDataVo);
|
|
|
+ MessageProperties messageProperties = new MessageProperties();
|
|
|
+ messageProperties.setMessageId(UUID.randomUUID().toString());
|
|
|
+ messageProperties.setContentType(CONTENT_TYPE_TEXT_PLAIN);
|
|
|
+ messageProperties.setContentEncoding("UTF-8");
|
|
|
+ Message message_cj = new Message(item.getBytes(StandardCharsets.UTF_8), messageProperties);
|
|
|
+ //推送
|
|
|
+ InsOrderPushMsg insOrderPushMsg = new InsOrderPushMsg(null, pushDataVo.getInsAreaCompany().getId(), "0", new Date(), pushDataVo.toString());
|
|
|
+ try{
|
|
|
+ //更新狀態
|
|
|
+ insOrderPushMsgService.save(insOrderPushMsg);
|
|
|
+ this.rabbitTemplate.convertAndSend(RabbitMqEnum.ORDER_EXCHANGE.getCode(), RabbitMqEnum.ORDER_ROUTINGKEY_SIGN.getCode(), message_cj);
|
|
|
+ Thread.sleep(1500);
|
|
|
+ }catch(Exception e){
|
|
|
+ e.getStackTrace();
|
|
|
+ }
|
|
|
});
|
|
|
}
|
|
|
- if(pushDataList!=null && !pushDataList.isEmpty()){
|
|
|
- Thread thread = new Thread(new OrderFailRunnableThread(rabbitTemplate, pushDataList,this));
|
|
|
- thread.start();
|
|
|
- }
|
|
|
}
|
|
|
/**
|
|
|
* @version
|
|
|
@@ -113,12 +137,29 @@ public class InsOrderPushMsgServiceImpl extends ServiceImpl<InsOrderPushMsgMappe
|
|
|
* @Description: 承保数据推送
|
|
|
*/
|
|
|
@Override
|
|
|
- public void getPushSignInsAreaCompanyList(String item) {
|
|
|
+ public void getPushSignInsAreaCompanyList(String orderId) {
|
|
|
try{
|
|
|
- ArrayList<String> pushDataList =new ArrayList<String>();
|
|
|
- pushDataList.add(getPushDataJsonString(item));
|
|
|
- Thread thread = new Thread(new OrderSignRunnableThread(rabbitTemplate, pushDataList,this));
|
|
|
- thread.start();
|
|
|
+ //ArrayList<String> pushDataList =new ArrayList<String>();
|
|
|
+ //pushDataList.add(getPushDataJsonString(item));
|
|
|
+ //Thread thread = new Thread(new OrderSignRunnableThread(rabbitTemplate, pushDataList,this));
|
|
|
+ //thread.start();
|
|
|
+ PushDataVo pushDataVo = getPushData(orderId);
|
|
|
+ String item = JSONObject.toJSONString(pushDataVo);
|
|
|
+ MessageProperties messageProperties = new MessageProperties();
|
|
|
+ messageProperties.setMessageId(UUID.randomUUID().toString());
|
|
|
+ messageProperties.setContentType(CONTENT_TYPE_TEXT_PLAIN);
|
|
|
+ messageProperties.setContentEncoding("UTF-8");
|
|
|
+ Message message_cj = new Message(item.getBytes(StandardCharsets.UTF_8), messageProperties);
|
|
|
+ //推送
|
|
|
+ InsOrderPushMsg insOrderPushMsg = new InsOrderPushMsg(null, pushDataVo.getInsAreaCompany().getId(), "0", new Date(), pushDataVo.toString());
|
|
|
+ try{
|
|
|
+ //更新狀態
|
|
|
+ insOrderPushMsgService.save(insOrderPushMsg);
|
|
|
+ this.rabbitTemplate.convertAndSend(RabbitMqEnum.ORDER_EXCHANGE.getCode(), RabbitMqEnum.ORDER_ROUTINGKEY_SIGN.getCode(), message_cj);
|
|
|
+
|
|
|
+ }catch(Exception e){
|
|
|
+ e.getStackTrace();
|
|
|
+ }
|
|
|
}catch(Exception e){
|
|
|
log.error(e.getMessage());
|
|
|
}
|
|
|
@@ -160,4 +201,21 @@ public class InsOrderPushMsgServiceImpl extends ServiceImpl<InsOrderPushMsgMappe
|
|
|
insAreaCompanyService.updateCompanyAndOrders(insAreaCompany);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ public PushDataVo getPushData(String orderId) {
|
|
|
+ //小订单的数据
|
|
|
+ InsAreaCompany insAreaCompany = insAreaCompanyService.getById(orderId);
|
|
|
+ //大订单数据
|
|
|
+ InsOrders orders = insOrdersService.getById(insAreaCompany.getOrderno());
|
|
|
+ String jyPolicyNo="";
|
|
|
+ String apiType = insAreaCompany.getApiType() == null ? null : insAreaCompany.getApiType() + "";
|
|
|
+ if (insAreaCompany.getCrossInsurance() != null) {
|
|
|
+ jyPolicyNo = OrderUtils.getJyPolicyNo(insAreaCompany.getCompanyId(), apiType, insAreaCompany.getCrossInsurance().toString(), String.valueOf(orders.getIsExternal()));
|
|
|
+ }
|
|
|
+ insAreaCompany.setJyPolicyNo(jyPolicyNo);
|
|
|
+ //影像数据
|
|
|
+ List<InsTaskImagesDto> taskImagesList = insTaskImagesMapper.getTaskImagesList(insAreaCompany.getOrderno());
|
|
|
+ PushDataVo pushDataVo =new PushDataVo(insAreaCompany,orders,taskImagesList);
|
|
|
+ return pushDataVo;
|
|
|
+ }
|
|
|
}
|