|
|
|
@ -1,9 +1,13 @@
|
|
|
|
|
package cn.iocoder.yudao.module.bs.service.quotationsheet;
|
|
|
|
|
|
|
|
|
|
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.query.QueryWrapperX;
|
|
|
|
|
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.quotationsheetdetail.QuotationSheetDetailDO;
|
|
|
|
|
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.quotationsheetdetail.QuotationSheetDetailService;
|
|
|
|
|
import cn.iocoder.yudao.module.bs.service.quotationsheetdetail.QuotationSheetDetailServiceImpl;
|
|
|
|
|
import cn.iocoder.yudao.module.bs.service.suppliercompany.SupplierCompanyService;
|
|
|
|
@ -17,6 +21,8 @@ import javax.annotation.Resource;
|
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.regex.Matcher;
|
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
import cn.iocoder.yudao.module.bs.controller.admin.quotationsheet.vo.*;
|
|
|
|
@ -47,11 +53,15 @@ public class QuotationSheetServiceImpl extends MPJBaseServiceImpl<QuotationSheet
|
|
|
|
|
@Resource
|
|
|
|
|
private SupplierCompanyService supplierCompanyService;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private MaterielService materielService;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Long createQuotationSheet(QuotationSheetCreateReqVO createReqVO) {
|
|
|
|
|
// 插入
|
|
|
|
|
QuotationSheetDO quotationSheet = QuotationSheetConvert.INSTANCE.convert(createReqVO);
|
|
|
|
|
quotationSheet.setSupplierIdAll(createReqVO.getSupplierIdList().toString());
|
|
|
|
|
quotationSheet.setNumber(numberCreate());
|
|
|
|
|
saveOrUpdate(quotationSheet);
|
|
|
|
|
if (createReqVO.getQuotationDetails().size() > 0){
|
|
|
|
|
//中间表插入数据
|
|
|
|
@ -105,6 +115,22 @@ public class QuotationSheetServiceImpl extends MPJBaseServiceImpl<QuotationSheet
|
|
|
|
|
if (null==quotationSheetDetailDOList){
|
|
|
|
|
quotationSheetDetailDOList = new ArrayList<>();
|
|
|
|
|
}
|
|
|
|
|
if (quotationSheetDetailDOList.size()>0){
|
|
|
|
|
List<MaterielDO> materielDOList = materielService.listByIds(quotationSheetDetailDOList.stream().map(QuotationSheetDetailDO::getMaterialId).collect(Collectors.toList()));
|
|
|
|
|
if (null!=materielDOList){
|
|
|
|
|
Map<Long, MaterielDO> map= materielDOList.stream().collect(Collectors.toMap(MaterielDO::getId, x ->x));
|
|
|
|
|
quotationSheetDetailDOList.forEach(a->{
|
|
|
|
|
MaterielDO materielDO = map.get(a.getMaterialId());
|
|
|
|
|
if (null!=materielDO){
|
|
|
|
|
a.setMaterielCode(materielDO.getMaterielCode());
|
|
|
|
|
a.setMaterielName(materielDO.getMaterielName());
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
quotationSheetDO.setSupplierList(supplierCompanyService.listByIds(JSON.parseArray(quotationSheetDO.getSupplierIdAll(),Long.class)));
|
|
|
|
|
quotationSheetDO.setQuotationDetails(quotationSheetDetailDOList);
|
|
|
|
|
return quotationSheetDO;
|
|
|
|
@ -119,6 +145,17 @@ public class QuotationSheetServiceImpl extends MPJBaseServiceImpl<QuotationSheet
|
|
|
|
|
if (null==quotationSheetDetailDOList){
|
|
|
|
|
quotationSheetDetailDOList = new ArrayList<>();
|
|
|
|
|
}
|
|
|
|
|
if (quotationSheetDetailDOList.size()>0){
|
|
|
|
|
List<MaterielDO> materielDOList = materielService.listByIds(quotationSheetDetailDOList.stream().map(QuotationSheetDetailDO::getMaterialId).collect(Collectors.toList()));
|
|
|
|
|
Map<Long, MaterielDO> map= materielDOList.stream().collect(Collectors.toMap(MaterielDO::getId, x ->x));
|
|
|
|
|
quotationSheetDetailDOList.forEach(q->{
|
|
|
|
|
MaterielDO materielDO = map.get(q.getMaterialId());
|
|
|
|
|
if (null!=materielDO){
|
|
|
|
|
q.setMaterielCode(materielDO.getMaterielCode());
|
|
|
|
|
q.setMaterielName(materielDO.getMaterielName());
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
a.setSupplierList(supplierCompanyService.listByIds(JSON.parseArray(a.getSupplierIdAll(),Long.class)));
|
|
|
|
|
a.setQuotationDetails(quotationSheetDetailDOList);
|
|
|
|
|
});
|
|
|
|
@ -129,13 +166,35 @@ public class QuotationSheetServiceImpl extends MPJBaseServiceImpl<QuotationSheet
|
|
|
|
|
@Override
|
|
|
|
|
public PageResult<QuotationSheetDO> getQuotationSheetPage(QuotationSheetPageReqVO pageReqVO) {
|
|
|
|
|
PageResult<QuotationSheetDO> sheetDOPageResult = quotationSheetMapper.selectPage(pageReqVO);
|
|
|
|
|
if (sheetDOPageResult.getList()!=null){
|
|
|
|
|
if (sheetDOPageResult.getList()!=null&&sheetDOPageResult.getList().size()>0){
|
|
|
|
|
List<MaterielDO> materielDOList = materielService.list(new QueryWrapper<MaterielDO>().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, MaterielDO> finalMap = map;
|
|
|
|
|
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)));
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
a.setSupplierList(supplierCompanyDOList);
|
|
|
|
|
a.setQuotationDetails(quotationSheetDetailDOList);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
@ -146,12 +205,18 @@ public class QuotationSheetServiceImpl extends MPJBaseServiceImpl<QuotationSheet
|
|
|
|
|
public List<QuotationSheetDO> getQuotationSheetList(QuotationSheetExportReqVO exportReqVO) {
|
|
|
|
|
List<QuotationSheetDO> quotationSheetDOList = quotationSheetMapper.selectList(exportReqVO);
|
|
|
|
|
|
|
|
|
|
if (quotationSheetDOList!=null){
|
|
|
|
|
if (quotationSheetDOList!=null&"ationSheetDOList.size()>0){
|
|
|
|
|
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));
|
|
|
|
|
}
|
|
|
|
|
List<MaterielDO> materielDOList = materielService.list(new QueryWrapper<MaterielDO>().eq("tenant_id",quotationSheetDOList.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, MaterielDO> finalMap = map;
|
|
|
|
|
Map<Long, List<QuotationSheetDetailDO>> finalSheetDetailMap = sheetDetailMap;
|
|
|
|
|
quotationSheetDOList.forEach(a->{
|
|
|
|
|
if (finalSheetDetailMap.size()>0){
|
|
|
|
@ -159,6 +224,17 @@ public class QuotationSheetServiceImpl extends MPJBaseServiceImpl<QuotationSheet
|
|
|
|
|
if (null==quotationSheetDetailDOS){
|
|
|
|
|
quotationSheetDetailDOS=new ArrayList<>();
|
|
|
|
|
}
|
|
|
|
|
if (quotationSheetDetailDOS.size()>0){
|
|
|
|
|
quotationSheetDetailDOS.forEach(q->{
|
|
|
|
|
if (finalMap.size()>0){
|
|
|
|
|
MaterielDO materielDO = finalMap.get(q.getMaterialId());
|
|
|
|
|
if (null!=materielDO){
|
|
|
|
|
q.setMaterielCode(materielDO.getMaterielCode());
|
|
|
|
|
q.setMaterielName(materielDO.getMaterielName());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
a.setQuotationDetails(quotationSheetDetailDOS);
|
|
|
|
|
}else {
|
|
|
|
|
a.setQuotationDetails(new ArrayList<>());
|
|
|
|
@ -170,4 +246,30 @@ public class QuotationSheetServiceImpl extends MPJBaseServiceImpl<QuotationSheet
|
|
|
|
|
return quotationSheetDOList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 编号生成方法
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private String numberCreate(){
|
|
|
|
|
long currentTime = System.currentTimeMillis();
|
|
|
|
|
Date date = new Date(currentTime);
|
|
|
|
|
String companyNumber="bjd"+ DateUtils.dateToStr(DateUtils.FORMAT_HOUR_MINUT,date);
|
|
|
|
|
QuotationSheetDO supplierCompanyDO = quotationSheetMapper.selectOne(new QueryWrapper<QuotationSheetDO>().like("number", companyNumber).orderByDesc("create_time").last("limit 1"));
|
|
|
|
|
if (null!=supplierCompanyDO){
|
|
|
|
|
Long aLong = numKun(supplierCompanyDO.getNumber());
|
|
|
|
|
companyNumber ="bjd"+(aLong+1);
|
|
|
|
|
}else {
|
|
|
|
|
companyNumber=companyNumber+"0000";
|
|
|
|
|
long l = numKun(companyNumber) + 1;
|
|
|
|
|
companyNumber ="bjd"+(numKun(companyNumber) + 1);
|
|
|
|
|
}
|
|
|
|
|
return companyNumber;
|
|
|
|
|
}
|
|
|
|
|
public Long numKun(String a){
|
|
|
|
|
String regEx = "[^0-9]";
|
|
|
|
|
Pattern p = Pattern.compile(regEx);
|
|
|
|
|
Matcher m = p.matcher(a);
|
|
|
|
|
String result = m.replaceAll("").trim();
|
|
|
|
|
return Long.valueOf(result);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|