|
|
@ -3,14 +3,20 @@ package cn.iocoder.yudao.module.bs.service.quotationsheet;
|
|
|
|
import cn.iocoder.yudao.framework.common.util.date.DateUtils;
|
|
|
|
import cn.iocoder.yudao.framework.common.util.date.DateUtils;
|
|
|
|
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
|
|
|
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
|
|
|
import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX;
|
|
|
|
import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX;
|
|
|
|
|
|
|
|
import cn.iocoder.yudao.framework.security.core.LoginUser;
|
|
|
|
import cn.iocoder.yudao.module.bs.dal.dataobject.expenseapplytrip.ExpenseApplyTripDO;
|
|
|
|
import cn.iocoder.yudao.module.bs.dal.dataobject.expenseapplytrip.ExpenseApplyTripDO;
|
|
|
|
import cn.iocoder.yudao.module.bs.dal.dataobject.materiel.MaterielDO;
|
|
|
|
import cn.iocoder.yudao.module.bs.dal.dataobject.materiel.MaterielDO;
|
|
|
|
|
|
|
|
import cn.iocoder.yudao.module.bs.dal.dataobject.quotationsheetbidding.QuotationSheetBiddingDO;
|
|
|
|
import cn.iocoder.yudao.module.bs.dal.dataobject.quotationsheetdetail.QuotationSheetDetailDO;
|
|
|
|
import cn.iocoder.yudao.module.bs.dal.dataobject.quotationsheetdetail.QuotationSheetDetailDO;
|
|
|
|
import cn.iocoder.yudao.module.bs.dal.dataobject.suppliercompany.SupplierCompanyDO;
|
|
|
|
import cn.iocoder.yudao.module.bs.dal.dataobject.suppliercompany.SupplierCompanyDO;
|
|
|
|
import cn.iocoder.yudao.module.bs.service.materiel.MaterielService;
|
|
|
|
import cn.iocoder.yudao.module.bs.service.materiel.MaterielService;
|
|
|
|
|
|
|
|
import cn.iocoder.yudao.module.bs.service.quotationsheetbidding.QuotationSheetBiddingService;
|
|
|
|
import cn.iocoder.yudao.module.bs.service.quotationsheetdetail.QuotationSheetDetailService;
|
|
|
|
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.quotationsheetdetail.QuotationSheetDetailServiceImpl;
|
|
|
|
import cn.iocoder.yudao.module.bs.service.suppliercompany.SupplierCompanyService;
|
|
|
|
import cn.iocoder.yudao.module.bs.service.suppliercompany.SupplierCompanyService;
|
|
|
|
|
|
|
|
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
|
|
|
|
|
|
|
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
|
|
|
|
|
|
|
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
@ -33,6 +39,7 @@ import cn.iocoder.yudao.module.bs.convert.quotationsheet.QuotationSheetConvert;
|
|
|
|
import cn.iocoder.yudao.module.bs.dal.mysql.quotationsheet.QuotationSheetMapper;
|
|
|
|
import cn.iocoder.yudao.module.bs.dal.mysql.quotationsheet.QuotationSheetMapper;
|
|
|
|
|
|
|
|
|
|
|
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
|
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
|
|
|
|
|
|
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUser;
|
|
|
|
import static cn.iocoder.yudao.module.bs.enums.ErrorCodeConstants.*;
|
|
|
|
import static cn.iocoder.yudao.module.bs.enums.ErrorCodeConstants.*;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -56,12 +63,25 @@ public class QuotationSheetServiceImpl extends MPJBaseServiceImpl<QuotationSheet
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private MaterielService materielService;
|
|
|
|
private MaterielService materielService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
|
|
|
private AdminUserApi adminUserApi;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
|
|
|
private QuotationSheetBiddingService quotationSheetBiddingService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
|
|
|
private DeptApi deptApi;
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public Long createQuotationSheet(QuotationSheetCreateReqVO createReqVO) {
|
|
|
|
public Long createQuotationSheet(QuotationSheetCreateReqVO createReqVO) {
|
|
|
|
// 插入
|
|
|
|
// 插入
|
|
|
|
QuotationSheetDO quotationSheet = QuotationSheetConvert.INSTANCE.convert(createReqVO);
|
|
|
|
QuotationSheetDO quotationSheet = QuotationSheetConvert.INSTANCE.convert(createReqVO);
|
|
|
|
quotationSheet.setSupplierIdAll(createReqVO.getSupplierIdList().toString());
|
|
|
|
quotationSheet.setSupplierIdAll(createReqVO.getSupplierIdList().toString());
|
|
|
|
quotationSheet.setNumber(numberCreate());
|
|
|
|
quotationSheet.setNumber(numberCreate());
|
|
|
|
|
|
|
|
LoginUser loginUser = getLoginUser();
|
|
|
|
|
|
|
|
AdminUserRespDTO user = adminUserApi.getUser(loginUser.getId());
|
|
|
|
|
|
|
|
quotationSheet.setDeptId(user.getDeptId());
|
|
|
|
|
|
|
|
quotationSheet.setApplicant(loginUser.getId());
|
|
|
|
saveOrUpdate(quotationSheet);
|
|
|
|
saveOrUpdate(quotationSheet);
|
|
|
|
if (createReqVO.getQuotationDetails().size() > 0){
|
|
|
|
if (createReqVO.getQuotationDetails().size() > 0){
|
|
|
|
//中间表插入数据
|
|
|
|
//中间表插入数据
|
|
|
@ -88,6 +108,7 @@ public class QuotationSheetServiceImpl extends MPJBaseServiceImpl<QuotationSheet
|
|
|
|
if (updateReqVO.getQuotationDetails().size() > 0){
|
|
|
|
if (updateReqVO.getQuotationDetails().size() > 0){
|
|
|
|
//中间表插入数据
|
|
|
|
//中间表插入数据
|
|
|
|
updateReqVO.getQuotationDetails().forEach(quotationSheetDetail -> {
|
|
|
|
updateReqVO.getQuotationDetails().forEach(quotationSheetDetail -> {
|
|
|
|
|
|
|
|
quotationSheetDetail.setId(null);
|
|
|
|
quotationSheetDetail.setCompanyId(updateObj.getId());
|
|
|
|
quotationSheetDetail.setCompanyId(updateObj.getId());
|
|
|
|
});
|
|
|
|
});
|
|
|
|
quotationSheetDetailService.saveBatch(updateReqVO.getQuotationDetails());
|
|
|
|
quotationSheetDetailService.saveBatch(updateReqVO.getQuotationDetails());
|
|
|
@ -246,6 +267,74 @@ public class QuotationSheetServiceImpl extends MPJBaseServiceImpl<QuotationSheet
|
|
|
|
return quotationSheetDOList;
|
|
|
|
return quotationSheetDOList;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public PageResult<QuotationSheetDO> getQuotationSheetPageBidding(QuotationSheetPageReqVO pageVO) {
|
|
|
|
|
|
|
|
PageResult<QuotationSheetDO> sheetDOPageResult = quotationSheetMapper.selectPage(pageVO);
|
|
|
|
|
|
|
|
if (sheetDOPageResult.getList()!=null&&sheetDOPageResult.getList().size()>0){
|
|
|
|
|
|
|
|
List<MaterielDO> materielDOList = materielService.list(new QueryWrapper<MaterielDO>().eq("tenant_id",sheetDOPageResult.getList().get(0).getTenantId()));
|
|
|
|
|
|
|
|
List<QuotationSheetBiddingDO> quotationSheetBiddingDOList = quotationSheetBiddingService.list(new QueryWrapper<QuotationSheetBiddingDO>().eq("tenant_id", sheetDOPageResult.getList().get(0).getTenantId()));
|
|
|
|
|
|
|
|
Map<Long, MaterielDO> map=new HashMap<>(2);
|
|
|
|
|
|
|
|
if (null!=materielDOList){
|
|
|
|
|
|
|
|
map= materielDOList.stream().collect(Collectors.toMap(MaterielDO::getId, x ->x));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Map<Long, List<QuotationSheetBiddingDO>> biddingMap=new HashMap<>(2);
|
|
|
|
|
|
|
|
if (null!=quotationSheetBiddingDOList&"ationSheetBiddingDOList.size()>0){
|
|
|
|
|
|
|
|
biddingMap= quotationSheetBiddingDOList.stream().collect(Collectors.groupingBy(QuotationSheetBiddingDO::getQuotationId));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Map<Long, MaterielDO> finalMap = map;
|
|
|
|
|
|
|
|
Map<Long, List<QuotationSheetBiddingDO>> finalBiddingMap = biddingMap;
|
|
|
|
|
|
|
|
sheetDOPageResult.getList().forEach(a->{
|
|
|
|
|
|
|
|
List<QuotationSheetDetailDO> quotationSheetDetailDOList = quotationSheetDetailService.list(new QueryWrapper<QuotationSheetDetailDO>().eq("company_id", a.getId()));
|
|
|
|
|
|
|
|
if (null==quotationSheetDetailDOList){
|
|
|
|
|
|
|
|
quotationSheetDetailDOList = new ArrayList<>();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (finalBiddingMap.size()>0){
|
|
|
|
|
|
|
|
List<QuotationSheetBiddingDO> sheetBiddingDOList = finalBiddingMap.get(a.getId());
|
|
|
|
|
|
|
|
if (null!=sheetBiddingDOList){
|
|
|
|
|
|
|
|
a.setQuotationSheetBiddingDOList(sheetBiddingDOList);
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
a.setQuotationSheetBiddingDOList(new ArrayList<>());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
a.setQuotationSheetBiddingDOList(new ArrayList<>());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (quotationSheetDetailDOList.size()>0){
|
|
|
|
|
|
|
|
quotationSheetDetailDOList.forEach(q->{
|
|
|
|
|
|
|
|
if (finalMap.size()>0){
|
|
|
|
|
|
|
|
MaterielDO materielDO = finalMap.get(q.getMaterialId());
|
|
|
|
|
|
|
|
if (null!=materielDO){
|
|
|
|
|
|
|
|
q.setMaterielCode(materielDO.getMaterielCode());
|
|
|
|
|
|
|
|
q.setMaterielName(materielDO.getMaterielName());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
List<SupplierCompanyDO> supplierCompanyDOList = supplierCompanyService.listByIds(JSON.parseArray(a.getSupplierIdAll(), Long.class));
|
|
|
|
|
|
|
|
if (null!=supplierCompanyDOList){
|
|
|
|
|
|
|
|
String collect = supplierCompanyDOList.stream().map(SupplierCompanyDO::getCompanyAme).collect(Collectors.toList()).stream().collect(Collectors.joining(","));
|
|
|
|
|
|
|
|
a.setSupplierNameList(collect);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (null!=a.getSupplierBiddingId()&&!"".equals(a.getSupplierBiddingId())){
|
|
|
|
|
|
|
|
List<SupplierCompanyDO> supplierCompanyDO = supplierCompanyService.listByIds(JSON.parseArray(a.getSupplierBiddingId(), Long.class));
|
|
|
|
|
|
|
|
if (null!=supplierCompanyDO){
|
|
|
|
|
|
|
|
a.setBiddingSupplierName(supplierCompanyDO.stream().map(SupplierCompanyDO::getCompanyAme).collect(Collectors.toList()).stream().collect(Collectors.joining(",")));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
a.setIsWin(1);
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
a.setIsWin(2);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
a.setSupplierList(supplierCompanyDOList);
|
|
|
|
|
|
|
|
a.setQuotationDetails(quotationSheetDetailDOList);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return sheetDOPageResult;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public String approvalBidding(QuotationSheetPageReqVO pageVO) {
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 编号生成方法
|
|
|
|
* 编号生成方法
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|