|
|
|
@ -1,10 +1,14 @@
|
|
|
|
|
package cn.iocoder.yudao.module.bs.service.quotationsheet;
|
|
|
|
|
|
|
|
|
|
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
|
|
|
|
import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX;
|
|
|
|
|
import cn.iocoder.yudao.module.bs.dal.dataobject.expenseapplytrip.ExpenseApplyTripDO;
|
|
|
|
|
import cn.iocoder.yudao.module.bs.dal.dataobject.quotationsheetdetail.QuotationSheetDetailDO;
|
|
|
|
|
import cn.iocoder.yudao.module.bs.service.quotationsheetdetail.QuotationSheetDetailService;
|
|
|
|
|
import cn.iocoder.yudao.module.bs.service.quotationsheetdetail.QuotationSheetDetailServiceImpl;
|
|
|
|
|
import cn.iocoder.yudao.module.bs.service.suppliercompany.SupplierCompanyService;
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
|
import com.github.yulichang.base.MPJBaseServiceImpl;
|
|
|
|
|
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
|
|
|
@ -13,6 +17,8 @@ import javax.annotation.Resource;
|
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
import cn.iocoder.yudao.module.bs.controller.admin.quotationsheet.vo.*;
|
|
|
|
|
import cn.iocoder.yudao.module.bs.dal.dataobject.quotationsheet.QuotationSheetDO;
|
|
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
|
@ -38,10 +44,14 @@ public class QuotationSheetServiceImpl extends MPJBaseServiceImpl<QuotationSheet
|
|
|
|
|
@Resource
|
|
|
|
|
private QuotationSheetDetailService quotationSheetDetailService;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private SupplierCompanyService supplierCompanyService;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Long createQuotationSheet(QuotationSheetCreateReqVO createReqVO) {
|
|
|
|
|
// 插入
|
|
|
|
|
QuotationSheetDO quotationSheet = QuotationSheetConvert.INSTANCE.convert(createReqVO);
|
|
|
|
|
quotationSheet.setSupplierIdAll(createReqVO.getSupplierIdList().toString());
|
|
|
|
|
saveOrUpdate(quotationSheet);
|
|
|
|
|
if (createReqVO.getQuotationDetails().size() > 0){
|
|
|
|
|
//中间表插入数据
|
|
|
|
@ -63,6 +73,7 @@ public class QuotationSheetServiceImpl extends MPJBaseServiceImpl<QuotationSheet
|
|
|
|
|
.eq(QuotationSheetDetailDO::getCompanyId,updateReqVO.getId()).eq(BaseDO::getDeleted,0));
|
|
|
|
|
// 更新
|
|
|
|
|
QuotationSheetDO updateObj = QuotationSheetConvert.INSTANCE.convert(updateReqVO);
|
|
|
|
|
updateObj.setSupplierIdAll(updateReqVO.getSupplierIdList().toString());
|
|
|
|
|
saveOrUpdate(updateObj);
|
|
|
|
|
if (updateReqVO.getQuotationDetails().size() > 0){
|
|
|
|
|
//中间表插入数据
|
|
|
|
@ -89,22 +100,74 @@ public class QuotationSheetServiceImpl extends MPJBaseServiceImpl<QuotationSheet
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public QuotationSheetDO getQuotationSheet(Long id) {
|
|
|
|
|
return quotationSheetMapper.selectById(id);
|
|
|
|
|
QuotationSheetDO quotationSheetDO = quotationSheetMapper.selectById(id);
|
|
|
|
|
List<QuotationSheetDetailDO> quotationSheetDetailDOList = quotationSheetDetailService.list(new QueryWrapper<QuotationSheetDetailDO>().eq("company_id", id));
|
|
|
|
|
if (null==quotationSheetDetailDOList){
|
|
|
|
|
quotationSheetDetailDOList = new ArrayList<>();
|
|
|
|
|
}
|
|
|
|
|
quotationSheetDO.setSupplierList(supplierCompanyService.listByIds(JSON.parseArray(quotationSheetDO.getSupplierIdAll(),Long.class)));
|
|
|
|
|
quotationSheetDO.setQuotationDetails(quotationSheetDetailDOList);
|
|
|
|
|
return quotationSheetDO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<QuotationSheetDO> getQuotationSheetList(Collection<Long> ids) {
|
|
|
|
|
return quotationSheetMapper.selectBatchIds(ids);
|
|
|
|
|
List<QuotationSheetDO> quotationSheetDOList = quotationSheetMapper.selectBatchIds(ids);
|
|
|
|
|
if (null!=quotationSheetDOList){
|
|
|
|
|
quotationSheetDOList.forEach(a->{
|
|
|
|
|
List<QuotationSheetDetailDO> quotationSheetDetailDOList = quotationSheetDetailService.list(new QueryWrapper<QuotationSheetDetailDO>().eq("company_id", a.getId()));
|
|
|
|
|
if (null==quotationSheetDetailDOList){
|
|
|
|
|
quotationSheetDetailDOList = new ArrayList<>();
|
|
|
|
|
}
|
|
|
|
|
a.setSupplierList(supplierCompanyService.listByIds(JSON.parseArray(a.getSupplierIdAll(),Long.class)));
|
|
|
|
|
a.setQuotationDetails(quotationSheetDetailDOList);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
return quotationSheetDOList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public PageResult<QuotationSheetDO> getQuotationSheetPage(QuotationSheetPageReqVO pageReqVO) {
|
|
|
|
|
return quotationSheetMapper.selectPage(pageReqVO);
|
|
|
|
|
PageResult<QuotationSheetDO> sheetDOPageResult = quotationSheetMapper.selectPage(pageReqVO);
|
|
|
|
|
if (sheetDOPageResult.getList()!=null){
|
|
|
|
|
sheetDOPageResult.getList().forEach(a->{
|
|
|
|
|
List<QuotationSheetDetailDO> quotationSheetDetailDOList = quotationSheetDetailService.list(new QueryWrapper<QuotationSheetDetailDO>().eq("company_id", a.getId()));
|
|
|
|
|
if (null==quotationSheetDetailDOList){
|
|
|
|
|
quotationSheetDetailDOList = new ArrayList<>();
|
|
|
|
|
}
|
|
|
|
|
a.setSupplierList(supplierCompanyService.listByIds(JSON.parseArray(a.getSupplierIdAll(),Long.class)));
|
|
|
|
|
a.setQuotationDetails(quotationSheetDetailDOList);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
return sheetDOPageResult;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<QuotationSheetDO> getQuotationSheetList(QuotationSheetExportReqVO exportReqVO) {
|
|
|
|
|
return quotationSheetMapper.selectList(exportReqVO);
|
|
|
|
|
List<QuotationSheetDO> quotationSheetDOList = quotationSheetMapper.selectList(exportReqVO);
|
|
|
|
|
|
|
|
|
|
if (quotationSheetDOList!=null){
|
|
|
|
|
List<QuotationSheetDetailDO> quotationSheetDetailDOList = quotationSheetDetailService.list(new QueryWrapper<QuotationSheetDetailDO>().eq("tenantId", quotationSheetDOList.get(0).getTenantId()));
|
|
|
|
|
Map<Long, List<QuotationSheetDetailDO>> sheetDetailMap =new HashMap<>(3);
|
|
|
|
|
if (null!=quotationSheetDetailDOList){
|
|
|
|
|
sheetDetailMap = quotationSheetDetailDOList.stream().collect(Collectors.groupingBy(QuotationSheetDetailDO::getCompanyId));
|
|
|
|
|
}
|
|
|
|
|
Map<Long, List<QuotationSheetDetailDO>> finalSheetDetailMap = sheetDetailMap;
|
|
|
|
|
quotationSheetDOList.forEach(a->{
|
|
|
|
|
if (finalSheetDetailMap.size()>0){
|
|
|
|
|
List<QuotationSheetDetailDO> quotationSheetDetailDOS = finalSheetDetailMap.get(a.getId());
|
|
|
|
|
if (null==quotationSheetDetailDOS){
|
|
|
|
|
quotationSheetDetailDOS=new ArrayList<>();
|
|
|
|
|
}
|
|
|
|
|
a.setQuotationDetails(quotationSheetDetailDOS);
|
|
|
|
|
}else {
|
|
|
|
|
a.setQuotationDetails(new ArrayList<>());
|
|
|
|
|
}
|
|
|
|
|
a.setSupplierList(supplierCompanyService.listByIds(JSON.parseArray(a.getSupplierIdAll(),Long.class)));
|
|
|
|
|
a.setQuotationDetails(quotationSheetDetailDOList);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
return quotationSheetDOList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|