Commit 2aaa902ea8c2a5460db24d8b82d4d0743d5eeb41
Merge branch 'master_chujiang_0805' into master_quotation
Showing
3 changed files
with
37 additions
and
11 deletions
xingyun-sc/src/main/java/com/lframework/xingyun/sc/impl/shipments/ShipmentsOrderInfoServiceImpl.java
| ... | ... | @@ -1141,17 +1141,7 @@ public class ShipmentsOrderInfoServiceImpl extends BaseMpServiceImpl<ShipmentsOr |
| 1141 | 1141 | // 【第一阶段:生成草稿】 |
| 1142 | 1142 | // 生成草稿要车单 |
| 1143 | 1143 | CreateDraftRequestCarTicketVo createVo = packDraftRequestCarTicket(orderInfo, plan.getTomoPreShipDate(), quantity); |
| 1144 | - draftRequestCarTicketService.create(createVo); | |
| 1145 | - // 发送消息提醒业务员补充数据 | |
| 1146 | - SysSiteMessageDto messageDto = new SysSiteMessageDto(); | |
| 1147 | - List<String> userIdList = new ArrayList<>(); | |
| 1148 | - userIdList.add(orderInfo.getContractCreateById()); | |
| 1149 | - messageDto.setUserIdList(userIdList); | |
| 1150 | - messageDto.setTitle("草稿要车单补充通知"); | |
| 1151 | - messageDto.setContent("您有新的草稿要车单需要补充,请尽快完成!订单编号:" + orderInfo.getOrderNo()); | |
| 1152 | - messageDto.setBizKey(IdUtil.getId()); | |
| 1153 | - messageDto.setCreateUserId(null); // 系统自动发起 | |
| 1154 | - mqProducerService.createSysSiteMessage(messageDto); | |
| 1144 | + draftRequestCarTicketService.createDraftAndNotify(createVo); | |
| 1155 | 1145 | |
| 1156 | 1146 | // 标记已生成新草稿 |
| 1157 | 1147 | hasNewDraftCreated = true; | ... | ... |
| ... | ... | @@ -12,6 +12,7 @@ import com.lframework.starter.common.exceptions.impl.DefaultClientException; |
| 12 | 12 | import com.lframework.starter.common.utils.Assert; |
| 13 | 13 | import com.lframework.starter.common.utils.ObjectUtil; |
| 14 | 14 | import com.lframework.starter.common.utils.StringUtil; |
| 15 | +import com.lframework.starter.mq.core.service.MqProducerService; | |
| 15 | 16 | import com.lframework.starter.web.core.annotations.oplog.OpLog; |
| 16 | 17 | import com.lframework.starter.web.core.components.resp.PageResult; |
| 17 | 18 | import com.lframework.starter.web.core.components.security.SecurityUtil; |
| ... | ... | @@ -21,6 +22,7 @@ import com.lframework.starter.web.core.utils.OpLogUtil; |
| 21 | 22 | import com.lframework.starter.web.core.utils.PageHelperUtil; |
| 22 | 23 | import com.lframework.starter.web.core.utils.PageResultUtil; |
| 23 | 24 | import com.lframework.starter.web.inner.components.oplog.OtherOpLogType; |
| 25 | +import com.lframework.starter.web.inner.dto.message.SysSiteMessageDto; | |
| 24 | 26 | import com.lframework.starter.web.inner.entity.SysUser; |
| 25 | 27 | import com.lframework.starter.web.inner.service.system.SysUserService; |
| 26 | 28 | import com.lframework.xingyun.sc.entity.DraftRequestCarTicket; |
| ... | ... | @@ -33,10 +35,12 @@ import com.lframework.xingyun.sc.vo.shipments.car.*; |
| 33 | 35 | import org.apache.commons.collections.CollectionUtils; |
| 34 | 36 | import org.apache.commons.lang3.StringUtils; |
| 35 | 37 | import org.springframework.stereotype.Service; |
| 38 | +import org.springframework.transaction.annotation.Propagation; | |
| 36 | 39 | import org.springframework.transaction.annotation.Transactional; |
| 37 | 40 | |
| 38 | 41 | import javax.annotation.Resource; |
| 39 | 42 | import java.io.Serializable; |
| 43 | +import java.util.ArrayList; | |
| 40 | 44 | import java.util.Collections; |
| 41 | 45 | import java.util.List; |
| 42 | 46 | import java.util.stream.Collectors; |
| ... | ... | @@ -54,6 +58,8 @@ public class DraftRequestCarTicketServiceImpl extends BaseMpServiceImpl<DraftReq |
| 54 | 58 | private SysUserService sysUserService; |
| 55 | 59 | @Resource |
| 56 | 60 | private ShipmentsPlanDetailService shipmentsPlanDetailService; |
| 61 | + @Resource | |
| 62 | + private MqProducerService mqProducerService; | |
| 57 | 63 | |
| 58 | 64 | @Override |
| 59 | 65 | public PageResult<DraftRequestCarTicket> query(Integer pageIndex, Integer pageSize, QueryDraftRequestCarTicketVo vo) { |
| ... | ... | @@ -314,6 +320,30 @@ public class DraftRequestCarTicketServiceImpl extends BaseMpServiceImpl<DraftReq |
| 314 | 320 | getBaseMapper().update(updateWrapper); |
| 315 | 321 | } |
| 316 | 322 | |
| 323 | + /** | |
| 324 | + * 独立事务:生成草稿要车单并发送通知 | |
| 325 | + * 使用 REQUIRES_NEW 确保即使外层事务回滚,这里的数据依然保留 | |
| 326 | + */ | |
| 327 | + @Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class) | |
| 328 | + public void createDraftAndNotify(CreateDraftRequestCarTicketVo vo) { | |
| 329 | + this.create(vo); | |
| 330 | + PurchaseOrderInfo info = purchaseOrderInfoService.findById(vo.getPurchaseOrderId()); | |
| 331 | + if (info == null) { | |
| 332 | + return; | |
| 333 | + } | |
| 334 | + | |
| 335 | + // 2. 发送消息提醒业务员补充数据 | |
| 336 | + SysSiteMessageDto messageDto = new SysSiteMessageDto(); | |
| 337 | + List<String> userIdList = new ArrayList<>(); | |
| 338 | + userIdList.add(info.getContractCreateById()); | |
| 339 | + messageDto.setUserIdList(userIdList); | |
| 340 | + messageDto.setTitle("草稿要车单补充通知"); | |
| 341 | + messageDto.setContent("您有新的草稿要车单需要补充,请尽快完成!订单编号:" + info.getOrderNo()); | |
| 342 | + messageDto.setBizKey(IdUtil.getId()); | |
| 343 | + messageDto.setCreateUserId(null); // 系统自动发起 | |
| 344 | + mqProducerService.createSysSiteMessage(messageDto); | |
| 345 | + } | |
| 346 | + | |
| 317 | 347 | @Override |
| 318 | 348 | public void cleanCacheByKey(Serializable key) { |
| 319 | 349 | ... | ... |
| ... | ... | @@ -84,4 +84,10 @@ public interface DraftRequestCarTicketService extends BaseMpService<DraftRequest |
| 84 | 84 | * @param flag 标识符 |
| 85 | 85 | */ |
| 86 | 86 | void freezeOrDeblocking(Boolean flag, List<String> orderIds); |
| 87 | + | |
| 88 | + /** | |
| 89 | + * 不走事务 | |
| 90 | + * @param vo | |
| 91 | + */ | |
| 92 | + void createDraftAndNotify(CreateDraftRequestCarTicketVo vo); | |
| 87 | 93 | } | ... | ... |