报价单

new
Agoni 1 year ago
parent d42448aa50
commit 52dd628b70

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.bs.controller.admin.quotationsheet;
import cn.iocoder.yudao.module.bs.service.materiel.MaterielService;
import cn.iocoder.yudao.module.bs.service.suppliercompany.SupplierCompanyService;
import com.alibaba.fastjson.JSON;
import org.springframework.web.bind.annotation.*;

@ -98,9 +98,6 @@ public class QuotationSheetBaseVO {
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime applyTime;
@Schema(description = "物料id集合")
private String materialIdList;
@Schema(description = "申请人")
private Long applicant;

@ -102,9 +102,6 @@ public class QuotationSheetExcelVO {
@ExcelProperty("申请人")
private Long applicant;
@ExcelProperty("物料id集合")
private String materialIdList;
@ExcelProperty("申请人部门id")
private Long deptId;

@ -97,9 +97,6 @@ public class QuotationSheetExportReqVO {
@Schema(description = "申请人")
private Long applicant;
@Schema(description = "物料id集合")
private String materialIdList;
@Schema(description = "申请人部门id", example = "10907")
private Long deptId;

@ -99,8 +99,8 @@ public class QuotationSheetPageReqVO extends PageParam {
@Schema(description = "申请人")
private Long applicant;
@Schema(description = "物料id集合")
private String materialIdList;
@Schema(description = "供应商id")
private String supplierCompanyId;
@Schema(description = "申请人部门id", example = "10907")
private Long deptId;

@ -28,6 +28,8 @@ public class QuotationSheetRespVO extends QuotationSheetBaseVO {
*/
private List<SupplierCompanyDO> supplierList;
private String supplierNameList;
private List<QuotationSheetDetailDO> quotationDetails;
}

@ -155,6 +155,9 @@ public class QuotationSheetDO extends TenantBaseDO {
*/
@TableField(exist = false)
private List<SupplierCompanyDO> supplierList;
@TableField(exist = false)
private String supplierNameList;
/**
*
*/

@ -1,5 +1,7 @@
package cn.iocoder.yudao.module.bs.dal.dataobject.quotationsheetdetail;
import cn.iocoder.yudao.framework.common.pojo.ImageVo;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import lombok.*;
import java.util.*;
import java.time.LocalDateTime;
@ -66,4 +68,23 @@ public class QuotationSheetDetailDO extends BaseDO {
*/
private String quality;
private String extend;
/**
*
*/
@TableField(exist = false)
private String materielCode;
/**
*
*/
@TableField(exist = false)
private String materielName;
/**
*
*/
@TableField(typeHandler = JacksonTypeHandler.class)
private List<ImageVo> files;
}

@ -45,7 +45,7 @@ public interface QuotationSheetMapper extends BaseMapperX<QuotationSheetDO> {
.eqIfPresent(QuotationSheetDO::getPurchaseContent, reqVO.getPurchaseContent())
.betweenIfPresent(QuotationSheetDO::getApplyTime, reqVO.getApplyTime())
.eqIfPresent(QuotationSheetDO::getApplicant, reqVO.getApplicant())
.eqIfPresent(QuotationSheetDO::getSupplierIdAll, reqVO.getMaterialIdList())
.likeIfPresent(QuotationSheetDO::getSupplierIdAll,reqVO.getSupplierCompanyId())
.eqIfPresent(QuotationSheetDO::getDeptId, reqVO.getDeptId())
.orderByDesc(QuotationSheetDO::getId));
}
@ -78,7 +78,7 @@ public interface QuotationSheetMapper extends BaseMapperX<QuotationSheetDO> {
.eqIfPresent(QuotationSheetDO::getPurchaseContent, reqVO.getPurchaseContent())
.betweenIfPresent(QuotationSheetDO::getApplyTime, reqVO.getApplyTime())
.eqIfPresent(QuotationSheetDO::getApplicant, reqVO.getApplicant())
.eqIfPresent(QuotationSheetDO::getSupplierIdAll, reqVO.getMaterialIdList())
// .likeIfPresent(QuotationSheetDO::getSupplierIdAll, reqVO.getSupplierCompanyId())
.eqIfPresent(QuotationSheetDO::getDeptId, reqVO.getDeptId())
.orderByDesc(QuotationSheetDO::getId));
}

@ -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&&quotationSheetDOList.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);
}
}

Loading…
Cancel
Save