[init]订单查询修改

master
NH-LHG 2 years ago
parent 42bcf26433
commit 168c2dde00

@ -5,11 +5,15 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import org.jeecg.modules.demo.erp.entity.ext.OrderDetailExt;
import org.jeecg.modules.demo.erp.entity.ext.OrderExt;
import org.jeecgframework.poi.excel.ExcelImportUtil; import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants; import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams; import org.jeecgframework.poi.excel.entity.ExportParams;
@ -69,14 +73,30 @@ public class OrderController {
//@AutoLog(value = "订单-分页列表查询") //@AutoLog(value = "订单-分页列表查询")
@ApiOperation(value="订单-分页列表查询", notes="订单-分页列表查询") @ApiOperation(value="订单-分页列表查询", notes="订单-分页列表查询")
@GetMapping(value = "/list") @GetMapping(value = "/list")
public Result<IPage<Order>> queryPageList(Order order, public Result<IPage<OrderExt>> queryPageList(Order order,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo, @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize, @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
HttpServletRequest req) { HttpServletRequest req) {
QueryWrapper<Order> queryWrapper = QueryGenerator.initQueryWrapper(order, req.getParameterMap()); QueryWrapper<Order> queryWrapper = QueryGenerator.initQueryWrapper(order, req.getParameterMap());
Page<Order> page = new Page<Order>(pageNo, pageSize); Page<Order> page = new Page<Order>(pageNo, pageSize);
IPage<Order> pageList = orderService.page(page, queryWrapper); IPage<Order> pageList = orderService.page(page, queryWrapper);
return Result.OK(pageList);
List<OrderDetailExt> orderDetailExtList = orderDetailService.selectByMainIdExt("");
Map<Long, List<OrderDetailExt>> orderDetailExtMap = orderDetailExtList
.stream()
.collect(
Collectors.groupingBy(OrderDetailExt::getOrderId)
);
Page<OrderExt> pageExt = new Page<>(pageNo, pageSize);
List<OrderExt> records = new ArrayList<>();
pageList.getRecords().forEach(e ->{
OrderExt orderExt = new OrderExt();
BeanUtils.copyProperties(e,orderExt);
orderExt.setOrderDetailList(orderDetailExtMap.get(e.getId()));
records.add(orderExt);
});
pageExt.setRecords(records);
return Result.OK(pageExt);
} }
/** /**

@ -0,0 +1,16 @@
package org.jeecg.modules.demo.erp.entity.ext;
import lombok.Data;
import org.jeecg.modules.demo.erp.entity.OrderDetail;
/**
* @author NH-LHG
*/
@Data
public class OrderDetailExt extends OrderDetail {
private java.lang.String factory;
private java.lang.String specs;
private java.lang.String category;
private java.lang.String unit;
private java.lang.String url;
}

@ -0,0 +1,16 @@
package org.jeecg.modules.demo.erp.entity.ext;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.jeecg.modules.demo.erp.entity.Order;
import java.util.List;
/**
* @author NH-LHG
*/
@Data
public class OrderExt extends Order {
@ApiModelProperty(value = "订单详情")
private List<OrderDetailExt> orderDetailList;
}

@ -4,6 +4,7 @@ import java.util.List;
import org.jeecg.modules.demo.erp.entity.OrderDetail; import org.jeecg.modules.demo.erp.entity.OrderDetail;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.jeecg.modules.demo.erp.entity.ext.OrderDetailExt;
/** /**
* @Description: * @Description:
@ -28,4 +29,14 @@ public interface OrderDetailMapper extends BaseMapper<OrderDetail> {
* @return List<OrderDetail> * @return List<OrderDetail>
*/ */
public List<OrderDetail> selectByMainId(@Param("mainId") String mainId); public List<OrderDetail> selectByMainId(@Param("mainId") String mainId);
/**
* id
*
* @param mainId id
* @return List<OrderDetailExt>
*/
public List<OrderDetailExt> selectByMainIdExt(@Param("mainId") String mainId);
} }

@ -13,4 +13,16 @@
FROM order_detail FROM order_detail
WHERE WHERE
order_id = #{mainId} </select> order_id = #{mainId} </select>
<select id="selectByMainIdExt" parameterType="java.lang.String" resultType="org.jeecg.modules.demo.erp.entity.ext.OrderDetailExt">
SELECT o.*,g.factory,g.specs,g.unit,g.url,g.category
FROM order_detail o,goods g
<where>
o.goods_id = g.id
<if test="mainId != null and mainId != ''">
and o.order_id = mainId;
</if>
</where>
</select>
</mapper> </mapper>

@ -2,6 +2,8 @@ package org.jeecg.modules.demo.erp.service;
import org.jeecg.modules.demo.erp.entity.OrderDetail; import org.jeecg.modules.demo.erp.entity.OrderDetail;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.demo.erp.entity.ext.OrderDetailExt;
import java.util.List; import java.util.List;
/** /**
@ -19,4 +21,11 @@ public interface IOrderDetailService extends IService<OrderDetail> {
* @return List<OrderDetail> * @return List<OrderDetail>
*/ */
public List<OrderDetail> selectByMainId(String mainId); public List<OrderDetail> selectByMainId(String mainId);
/**
* id
*
* @param mainId id
* @return List<OrderDetail>
*/
public List<OrderDetailExt> selectByMainIdExt(String mainId);
} }

@ -1,6 +1,7 @@
package org.jeecg.modules.demo.erp.service.impl; package org.jeecg.modules.demo.erp.service.impl;
import org.jeecg.modules.demo.erp.entity.OrderDetail; import org.jeecg.modules.demo.erp.entity.OrderDetail;
import org.jeecg.modules.demo.erp.entity.ext.OrderDetailExt;
import org.jeecg.modules.demo.erp.mapper.OrderDetailMapper; import org.jeecg.modules.demo.erp.mapper.OrderDetailMapper;
import org.jeecg.modules.demo.erp.service.IOrderDetailService; import org.jeecg.modules.demo.erp.service.IOrderDetailService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -24,4 +25,10 @@ public class OrderDetailServiceImpl extends ServiceImpl<OrderDetailMapper, Order
public List<OrderDetail> selectByMainId(String mainId) { public List<OrderDetail> selectByMainId(String mainId) {
return orderDetailMapper.selectByMainId(mainId); return orderDetailMapper.selectByMainId(mainId);
} }
@Override
public List<OrderDetailExt> selectByMainIdExt(String mainId) {
return orderDetailMapper.selectByMainIdExt(mainId);
}
} }

@ -1,7 +1,6 @@
package org.jeecg.modules.system.entity; package org.jeecg.modules.system.entity;
import java.io.Serializable; import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date; import java.util.Date;
import org.jeecgframework.poi.excel.annotation.Excel; import org.jeecgframework.poi.excel.annotation.Excel;

Loading…
Cancel
Save