[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.List;
import java.util.Map;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
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.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
@ -69,14 +73,30 @@ public class OrderController {
//@AutoLog(value = "订单-分页列表查询")
@ApiOperation(value="订单-分页列表查询", notes="订单-分页列表查询")
@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="pageSize", defaultValue="10") Integer pageSize,
HttpServletRequest req) {
QueryWrapper<Order> queryWrapper = QueryGenerator.initQueryWrapper(order, req.getParameterMap());
Page<Order> page = new Page<Order>(pageNo, pageSize);
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 com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.jeecg.modules.demo.erp.entity.ext.OrderDetailExt;
/**
* @Description:
@ -28,4 +29,14 @@ public interface OrderDetailMapper extends BaseMapper<OrderDetail> {
* @return List<OrderDetail>
*/
public List<OrderDetail> selectByMainId(@Param("mainId") String mainId);
/**
* id
*
* @param mainId id
* @return List<OrderDetailExt>
*/
public List<OrderDetailExt> selectByMainIdExt(@Param("mainId") String mainId);
}

@ -3,14 +3,26 @@
<mapper namespace="org.jeecg.modules.demo.erp.mapper.OrderDetailMapper">
<delete id="deleteByMainId" parameterType="java.lang.String">
DELETE
FROM order_detail
DELETE
FROM order_detail
WHERE
order_id = #{mainId} </delete>
<select id="selectByMainId" parameterType="java.lang.String" resultType="org.jeecg.modules.demo.erp.entity.OrderDetail">
SELECT *
SELECT *
FROM order_detail
WHERE
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>

@ -2,6 +2,8 @@ package org.jeecg.modules.demo.erp.service;
import org.jeecg.modules.demo.erp.entity.OrderDetail;
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.demo.erp.entity.ext.OrderDetailExt;
import java.util.List;
/**
@ -19,4 +21,11 @@ public interface IOrderDetailService extends IService<OrderDetail> {
* @return List<OrderDetail>
*/
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;
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.service.IOrderDetailService;
import org.springframework.stereotype.Service;
@ -16,12 +17,18 @@ import org.springframework.beans.factory.annotation.Autowired;
*/
@Service
public class OrderDetailServiceImpl extends ServiceImpl<OrderDetailMapper, OrderDetail> implements IOrderDetailService {
@Autowired
private OrderDetailMapper orderDetailMapper;
@Override
public List<OrderDetail> selectByMainId(String 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;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date;
import org.jeecgframework.poi.excel.annotation.Excel;
@ -35,19 +34,19 @@ public class SysRole implements Serializable {
*/
@TableId(type = IdType.ASSIGN_ID)
private String id;
/**
*
*/
@Excel(name="角色名",width=15)
private String roleName;
/**
*
*/
@Excel(name="角色编码",width=15)
private String roleCode;
/**
*
*/

Loading…
Cancel
Save