采购单 报价单 物料

new
Agoni 1 year ago
parent 3fb990a4bd
commit d42448aa50

@ -1,5 +1,7 @@
package cn.iocoder.yudao.module.bs.controller.admin.quotationsheet;
import cn.iocoder.yudao.module.bs.service.suppliercompany.SupplierCompanyService;
import com.alibaba.fastjson.JSON;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;

@ -13,9 +13,9 @@ import javax.validation.constraints.*;
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class QuotationSheetCreateReqVO extends QuotationSheetBaseVO {
/* @Schema(description = "物料id集合", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "物料id集合不能为空")
private List<Long> suppliesIdList;*/
@Schema(description = "供应商id集合", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "供应商id集合不能为空")
private List<Long> supplierIdList;
@NotEmpty(message = "物料不能为空")
private List<QuotationSheetDetailDO> quotationDetails;

@ -2,8 +2,12 @@ package cn.iocoder.yudao.module.bs.controller.admin.quotationsheet.vo;
import cn.iocoder.yudao.module.bs.dal.dataobject.quotationsheet.QuotationSheetDO;
import cn.iocoder.yudao.module.bs.dal.dataobject.quotationsheetdetail.QuotationSheetDetailDO;
import cn.iocoder.yudao.module.bs.dal.dataobject.suppliercompany.SupplierCompanyDO;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import org.apache.poi.ss.formula.functions.T;
import java.time.LocalDateTime;
import java.util.List;
@ -19,6 +23,10 @@ public class QuotationSheetRespVO extends QuotationSheetBaseVO {
@Schema(description = "创建时间")
private LocalDateTime createTime;
/**
*
*/
private List<SupplierCompanyDO> supplierList;
private List<QuotationSheetDetailDO> quotationDetails;

@ -16,6 +16,9 @@ public class QuotationSheetUpdateReqVO extends QuotationSheetBaseVO {
@NotNull(message = "主键不能为空")
private Long id;
@Schema(description = "供应商id集合", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "供应商id集合不能为空")
private List<Long> supplierIdList;
@NotEmpty(message = "物料不能为空")
private List<QuotationSheetDetailDO> quotationDetails;

@ -31,7 +31,7 @@ public class QuotationSheetDetailBaseVO {
private Long companyId;
@Schema(description = "规格")
private String desc;
private String getDescStr;
@Schema(description = "用量")
private Integer dosage;

@ -30,6 +30,9 @@ public class MaterielDO extends TenantBaseDO {
*/
@TableId
private Long id;
private Long tenantId;
/**
*
*/

@ -2,6 +2,8 @@ package cn.iocoder.yudao.module.bs.dal.dataobject.quotationsheet;
import cn.iocoder.yudao.framework.common.pojo.ImageVo;
import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO;
import cn.iocoder.yudao.module.bs.dal.dataobject.quotationsheetdetail.QuotationSheetDetailDO;
import cn.iocoder.yudao.module.bs.dal.dataobject.suppliercompany.SupplierCompanyDO;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
@ -14,6 +16,9 @@ import java.time.LocalDateTime;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.*;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import org.apache.poi.ss.formula.functions.T;
import javax.validation.constraints.NotEmpty;
/**
* DO
@ -137,12 +142,22 @@ public class QuotationSheetDO extends TenantBaseDO {
*/
private Long applicant;
/**
* id
* id
*/
private String materialIdList;
private String supplierIdAll;
/**
* id
*/
private Long deptId;
/**
*
*/
@TableField(exist = false)
private List<SupplierCompanyDO> supplierList;
/**
*
*/
@TableField(exist = false)
private List<QuotationSheetDetailDO> quotationDetails;
}

@ -27,6 +27,8 @@ public class QuotationSheetDetailDO extends BaseDO {
*/
@TableId
private Long id;
private Long tenantId;
/**
*
*/
@ -50,7 +52,7 @@ public class QuotationSheetDetailDO extends BaseDO {
/**
*
*/
private String desc;
private String descStr;
/**
*
*/

@ -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::getMaterialIdList, reqVO.getMaterialIdList())
.eqIfPresent(QuotationSheetDO::getSupplierIdAll, reqVO.getMaterialIdList())
.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::getMaterialIdList, reqVO.getMaterialIdList())
.eqIfPresent(QuotationSheetDO::getSupplierIdAll, reqVO.getMaterialIdList())
.eqIfPresent(QuotationSheetDO::getDeptId, reqVO.getDeptId())
.orderByDesc(QuotationSheetDO::getId));
}

@ -25,7 +25,7 @@ public interface QuotationSheetDetailMapper extends BaseMapperX<QuotationSheetDe
.eqIfPresent(QuotationSheetDetailDO::getMaterialCode, reqVO.getMaterialCode())
.eqIfPresent(QuotationSheetDetailDO::getMaterialId, reqVO.getMaterialId())
.eqIfPresent(QuotationSheetDetailDO::getCompanyId, reqVO.getCompanyId())
.eqIfPresent(QuotationSheetDetailDO::getDesc, reqVO.getDesc())
.eqIfPresent(QuotationSheetDetailDO::getDescStr, reqVO.getDesc())
.eqIfPresent(QuotationSheetDetailDO::getDosage, reqVO.getDosage())
.eqIfPresent(QuotationSheetDetailDO::getUnti, reqVO.getUnti())
.eqIfPresent(QuotationSheetDetailDO::getQuality, reqVO.getQuality())
@ -40,7 +40,7 @@ public interface QuotationSheetDetailMapper extends BaseMapperX<QuotationSheetDe
.eqIfPresent(QuotationSheetDetailDO::getMaterialCode, reqVO.getMaterialCode())
.eqIfPresent(QuotationSheetDetailDO::getMaterialId, reqVO.getMaterialId())
.eqIfPresent(QuotationSheetDetailDO::getCompanyId, reqVO.getCompanyId())
.eqIfPresent(QuotationSheetDetailDO::getDesc, reqVO.getDesc())
.eqIfPresent(QuotationSheetDetailDO::getDescStr, reqVO.getDesc())
.eqIfPresent(QuotationSheetDetailDO::getDosage, reqVO.getDosage())
.eqIfPresent(QuotationSheetDetailDO::getUnti, reqVO.getUnti())
.eqIfPresent(QuotationSheetDetailDO::getQuality, reqVO.getQuality())

@ -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;
}
}

Loading…
Cancel
Save