package com.meishi.mall.modules.inquiry.entity.vo;
import com.meishi.mall.modules.inquiry.entity.dto.SaleInquiryDto;
import lombok.Data;
import java.util.Date;
import java.util.List;
@Data
public class MakeInquiryVo {
private String id;
private String billNo;
private Date crtTime;
List<SaleInquiryDto> items;
}
该实体为编号对应多个数据内容
package com.meishi.mall.modules.inquiry.entity.dto;
import com.baomidou.mybatisplus.annotations.TableField;
import lombok.Data;
import java.util.Date;
@Data
public class SaleInquiryDto {
private String qty;
private String price;
private String itemNo;
private String specModel;
private String billStatus;
private String skuName;
private String deliveryTime;
private Date disabledDate;
private String crtTime;
private String billNo;
private String brandName;
private String goodsId;
private String quotePrice;
private String productPic;
}
/**
* 获取最终数据
*/
List<MakeInquiryVo> selectInquiry(@Param("billNo") List<String> billNo,@Param("inquiryDto") InquiryDto inquiryDto);
此时注意一对多的关系(如果MakeInquiryVo显示数据非集合数据,而集合数据SaleInquiryDto也有该数据,数据重了)必须写 MakeInquiryVo对应的数据如(billNo和对应的的时间)
<!--resultMap -->
<resultMap id="ResultMapInquiry" type="com.meishi.mall.modules.inquiry.entity.vo.MakeInquiryVo">
<id column="id" property="id"/>
<result column="billNo" property="billNo"/>
<result column="crtTime" property="crtTime"/>
<collection property="items" ofType="com.meishi.mall.modules.inquiry.entity.dto.SaleInquiryDto">
<id property="qty" column="items.qty"/>
<id property="price" column="items.price"/>
<id property="itemNo" column="items.itemNo"/>
<id property="billStatus" column="items.billStatus"/>
<id property="skuName" column="items.skuName"/>
<id property="deliveryTime" column="items.deliveryTime"/>
<id property="disabledDate" column="items.disabledDate"/>
<id property="brandName" column="items.brandName"/>
<id property="goodsId" column="items.goodsId"/>
<id property="quotePrice" column="items.quotePrice"/>
<id property="productPic" column="items.productPic"/>
<id property="specModel" column="items.specModel"/>
</collection>
</resultMap>
<select id="selectInquiry" resultMap="ResultMapInquiry">
SELECT
oy.id AS id,
oy.bill_no AS billNo,
oy.crt_time AS crtTime,
oy.bill_status AS "items.billStatus",
oy.disabled_date AS "items.disabledDate",
om.brand_name AS "items.brandName",
om.qty AS "items.qty",
om.quote_price AS "items.quotePrice",
om.sku_name AS "items.skuName",
om.item_no AS "items.itemNo",
om.goods_id AS "items.goodsId",
om.spec_model AS "items.specModel",
om.delivery_time AS "items.deliveryTime",
om.productPic AS "items.productPic"
FROM `oms_sale_inquiry` oy
LEFT JOIN `oms_sale_inquiry_item` om ON om.`bill_no`=oy.`bill_no`
WHERE
<!-- 将得到的编号遍历存在对应实体类中-->
oy.bill_no IN
<foreach collection="billNo" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
<if test="inquiryDto.customerId!=null and inquiryDto.customerId.trim()!=''">
AND oy.customer_id = #{inquiryDto.customerId}
</if>
<if test="inquiryDto.billStatus!=null and inquiryDto.billStatus.trim()!=''">
AND oy.`bill_status` = #{inquiryDto.billStatus}
</if>
<if test="inquiryDto.number!=null and inquiryDto.number.trim()!=''">
AND oy.bill_no = #{inquiryDto.number}
</if>
<if test="inquiryDto.dateOne!=null and inquiryDto.dateOne.trim()!=''">
AND oy.crt_time >= #{inquiryDto.dateOne}
</if>
<if test="inquiryDto.dateTwo!=null and inquiryDto.dateTwo.trim()!=''">
AND oy.crt_time <= #{inquiryDto.dateTwo}
</if>
order by oy.crt_time DESC
</select>
编写对应的service层以及实现类
Map<String, Object> selectPageALLItem(Map<String, Object> params);
实现类
@Override
public Map<String, Object> selectPageALLItem(Map<String, Object> params) {
Page<InquiryDto> page = new Query<>(params);
//将分页传过来的参数params封装到InquiryDto对象中
InquiryDto inquiryDto = BeanUtil.mapToBean(params, InquiryDto.class, true);
List<OmsSaleInquiry> omsSaleInquiries = omsSaleInquiryMapper.selectSumInquiry(page, inquiryDto);
Integer count = omsSaleInquiryMapper.selectAllDocuments(inquiryDto);
//获取编号的集合
List<String> collect = omsSaleInquiries.stream().map(OmsSaleInquiry::getBillNo).collect(Collectors.toList());
List<MakeInquiryVo> voList = null;
if (collect.size() != 0) {
voList = omsSaleInquiryItemMapper.selectInquiry(collect, inquiryDto);
}
Map<String, Object> map = Maps.newHashMap();
map.put("records", voList);
map.put("total", count);
return map;
}
@ApiOperation("加入询价")
@PostMapping(value = "/getInquiry")
public ActionResult<Map<String, Object>> getInquiry(@RequestParam Map<String, Object> params) {
Map<String, Object> map = iOmsSaleInquiryItemService.selectPageALLItem(params);
return new ActionResult<>(StatusCode.SUCCESS, map);
}