| | |
| | | package com.ruoyi.tms.service.impl; |
| | | |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import com.ruoyi.common.enums.SystemDataNoEnum; |
| | | import com.ruoyi.common.utils.DateUtils; |
| | |
| | | |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.system.service.ISystemDataNoService; |
| | | import com.ruoyi.tms.domain.TmsQuoteItem; |
| | | import com.ruoyi.tms.service.ITmsQuoteItemService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | protected final Logger logger = LoggerFactory.getLogger(getClass()); |
| | | @Resource |
| | | private TmsQuotePlanMapper tmsQuotePlanMapper; |
| | | @Autowired |
| | | private ITmsQuoteItemService tmsQuoteItemService; |
| | | |
| | | @Autowired |
| | | ISystemDataNoService systemDataNoService; |
| | |
| | | @Override |
| | | public TmsQuotePlan selectTmsQuotePlanById(Integer id) |
| | | { |
| | | return tmsQuotePlanMapper.selectTmsQuotePlanById(id); |
| | | TmsQuotePlan tmsQuotePlan = tmsQuotePlanMapper.selectTmsQuotePlanById(id); |
| | | tmsQuotePlan.setQuoteItems(tmsQuoteItemService.selectTmsQuoteItemList(new TmsQuoteItem(){{setQuotePlanId(id);}})); |
| | | return tmsQuotePlan; |
| | | } |
| | | |
| | | /** |
| | |
| | | tmsQuotePlan.setSystemCode(noByKey); |
| | | tmsQuotePlan.setCreateBy(SecurityUtils.getUsername()); |
| | | tmsQuotePlan.setCreateTime(DateUtils.getNowDate()); |
| | | return tmsQuotePlanMapper.insertTmsQuotePlan(tmsQuotePlan); |
| | | tmsQuotePlanMapper.insertTmsQuotePlan(tmsQuotePlan); |
| | | |
| | | List<TmsQuoteItem> quoteItems = tmsQuotePlan.getQuoteItems(); |
| | | if (quoteItems != null && !quoteItems.isEmpty()){ |
| | | quoteItems.forEach(tmsQuoteItem -> { |
| | | tmsQuoteItem.setQuotePlanId(tmsQuotePlan.getId()); |
| | | }); |
| | | tmsQuoteItemService.insertTmsQuoteItemBatch(quoteItems); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | /** |
| | |
| | | { |
| | | tmsQuotePlan.setUpdateBy(SecurityUtils.getUsername()); |
| | | tmsQuotePlan.setUpdateTime(DateUtils.getNowDate()); |
| | | return tmsQuotePlanMapper.updateTmsQuotePlan(tmsQuotePlan); |
| | | int i = tmsQuotePlanMapper.updateTmsQuotePlan(tmsQuotePlan); |
| | | |
| | | |
| | | |
| | | List<TmsQuoteItem> quoteItems = tmsQuotePlan.getQuoteItems(); |
| | | if (quoteItems != null && !quoteItems.isEmpty()){ |
| | | List<TmsQuoteItem> tmsQuoteItems = tmsQuoteItemService.selectTmsQuoteItemList(new TmsQuoteItem() {{ |
| | | setQuotePlanId(tmsQuotePlan.getId()); |
| | | }}); |
| | | |
| | | // 1、删除本次提交没有的数据 |
| | | List<Integer> collect = quoteItems.stream().map(TmsQuoteItem::getId).collect(Collectors.toList()); |
| | | tmsQuoteItems.removeIf(tmsQuoteItem -> collect.contains(tmsQuoteItem.getId())); |
| | | List<Integer> collect1 = tmsQuoteItems.stream().map(TmsQuoteItem::getId).collect(Collectors.toList()); |
| | | if (!collect1.isEmpty()){ |
| | | tmsQuoteItemService.getBaseMapper().deleteBatchIds(collect1); |
| | | } |
| | | |
| | | // 2、更新本次提交有的数据 |
| | | List<TmsQuoteItem> collect2 = quoteItems.stream().filter(tmsQuoteItem -> tmsQuoteItem.getId() != null).collect(Collectors.toList()); |
| | | if (!collect2.isEmpty()){ |
| | | tmsQuoteItemService.updateTmsQuoteItemBatch(collect2); |
| | | } |
| | | // 3、新增本次提交没有的数据 |
| | | List<TmsQuoteItem> collect3 = quoteItems.stream(). |
| | | filter(tmsQuoteItem -> tmsQuoteItem.getId() == null).collect(Collectors.toList()); |
| | | |
| | | if (!collect3.isEmpty()){ |
| | | collect3.forEach(tmsQuoteItem -> tmsQuoteItem.setQuotePlanId(tmsQuotePlan.getId())); |
| | | tmsQuoteItemService.insertTmsQuoteItemBatch(collect3); |
| | | } |
| | | |
| | | |
| | | } |
| | | return i; |
| | | } |
| | | |
| | | /** |