|
|
|
@ -1,10 +1,16 @@ |
|
|
|
package com.spring.modules.quote.service.impl; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
import com.spring.ifs.bean.BaseSearchBean; |
|
|
|
import com.spring.modules.part.entity.PartInformationEntity; |
|
|
|
import com.spring.modules.part.vo.InventoryPartUnitCostSumVo; |
|
|
|
import com.spring.modules.quote.entity.*; |
|
|
|
import com.spring.modules.quote.mapper.QuoteDetailBomTreeMapper; |
|
|
|
import com.spring.modules.quote.service.*; |
|
|
|
import com.spring.modules.sys.entity.SysUserEntity; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.shiro.SecurityUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
@ -25,6 +31,8 @@ public class QuoteDetailBomTreeServiceImpl extends ServiceImpl<QuoteDetailBomTre |
|
|
|
private QuoteDetailRoutingService quoteDetailRoutingService; |
|
|
|
@Autowired |
|
|
|
private QuoteDetailToolService quoteDetailToolService; |
|
|
|
@Autowired |
|
|
|
private BaseSearchBean baseSearchBean; |
|
|
|
@Override |
|
|
|
@Transactional |
|
|
|
public void initQuoteDetailBomTree(QuoteDetail detail, Long parentId, Integer level) { |
|
|
|
@ -46,12 +54,12 @@ public class QuoteDetailBomTreeServiceImpl extends ServiceImpl<QuoteDetailBomTre |
|
|
|
quoteDetailRoutingService.saveQuoteDetailRouting(routing); |
|
|
|
} |
|
|
|
if (parentId.equals(0L)){ |
|
|
|
// 1、清空工具信息 |
|
|
|
quoteDetailToolService.lambdaUpdate() |
|
|
|
.eq(QuoteDetailTool::getQuoteDetailId, detail.getId()) |
|
|
|
.remove(); |
|
|
|
if (Objects.nonNull(routing)){ |
|
|
|
// 处理工具 |
|
|
|
// 1、清空工具信息 |
|
|
|
quoteDetailToolService.lambdaUpdate() |
|
|
|
.eq(QuoteDetailTool::getQuoteDetailId, detail.getId()) |
|
|
|
.remove(); |
|
|
|
// 2、根据routing 生成工具信息 |
|
|
|
quoteDetailToolService.saveToolByRouting(routing); |
|
|
|
// 3、插入一条其他工具信息 |
|
|
|
@ -68,6 +76,27 @@ public class QuoteDetailBomTreeServiceImpl extends ServiceImpl<QuoteDetailBomTre |
|
|
|
component.setCreateBy(detail.getCreateBy()); |
|
|
|
component.setCreateDate(detail.getCreateDate()); |
|
|
|
QuoteDetail quoteDetail = createQuoteDetail(detail, component); |
|
|
|
// Part是正式料号需要从IFS获得成本信息 |
|
|
|
if ("Y".equals(component.getStatus())){ |
|
|
|
SysUserEntity user = (SysUserEntity)SecurityUtils.getSubject().getPrincipal(); |
|
|
|
PartInformationEntity part = new PartInformationEntity(); |
|
|
|
part.setSite(component.getSite()); |
|
|
|
part.setPartNo(component.getPartNo()); |
|
|
|
Map<String, String> map = baseSearchBean.getInventoryValueByPartNo(user.getServer(), part); |
|
|
|
if (Objects.equals(map.get("resultCode"),"200")){ |
|
|
|
// 返回成功 将成本 |
|
|
|
InventoryPartUnitCostSumVo unitCostSumVo = JSONObject.parseObject(map.get("obj"), InventoryPartUnitCostSumVo.class); |
|
|
|
try { |
|
|
|
BigDecimal unitCost = new BigDecimal(unitCostSumVo.getInventoryValue()); |
|
|
|
component.setUnitPrice(unitCost); |
|
|
|
component.setActualPrice(unitCost); |
|
|
|
component.setQuotePrice(unitCost); |
|
|
|
}catch (Exception e){ |
|
|
|
log.error("PartNo:{},Site:{},成本信息异常:{}",component.getPartNo(),component.getSite(),e.getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
// 物料是半成品 |
|
|
|
if (isComponentBom(quoteDetail)){ |
|
|
|
initQuoteDetailBomTree(quoteDetail ,bom.getId(),level+1); |
|
|
|
} |
|
|
|
|