package com.zy.asrs.controller;
|
|
import com.alibaba.fastjson.JSONObject;
|
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
import com.baomidou.mybatisplus.mapper.Wrapper;
|
import com.baomidou.mybatisplus.plugins.Page;
|
import com.core.annotations.ManagerAuth;
|
import com.core.common.BaseRes;
|
import com.core.common.Cools;
|
import com.core.common.DateUtils;
|
import com.core.common.R;
|
import com.zy.asrs.entity.DocType;
|
import com.zy.asrs.entity.OrderPakout;
|
import com.zy.asrs.entity.OrderReport;
|
import com.zy.asrs.service.DocTypeService;
|
import com.zy.asrs.service.OrderDetlReportService;
|
import com.zy.asrs.service.OrderReportService;
|
import com.zy.common.web.BaseController;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.*;
|
|
import java.util.*;
|
|
@RestController
|
@RequestMapping(value = "/report")
|
public class OrderReportController extends BaseController {
|
|
@Autowired
|
private OrderReportService orderReportService;
|
@Autowired
|
private OrderDetlReportService orderDetlReportService;
|
|
@Autowired
|
private DocTypeService docTypeService;
|
|
|
@RequestMapping(value = "/order/head/page/auth")
|
@ManagerAuth
|
public R head(@RequestParam(defaultValue = "1") Integer curr,
|
@RequestParam(defaultValue = "10") Integer limit,
|
@RequestParam(required = false) String orderByField,
|
@RequestParam(required = false) String orderByType,
|
@RequestParam Map<String, Object> param) {
|
EntityWrapper<OrderReport> wrapper = new EntityWrapper<>();
|
excludeTrash(param);
|
convert(param, wrapper);
|
if (!Cools.isEmpty(orderByField)) {
|
wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));
|
} else {
|
wrapper.orderBy("settle").orderBy("create_time", false);
|
}
|
wrapper.eq("status", 1);
|
return R.ok(orderReportService.selectPage(new Page<>(curr, limit), wrapper));
|
}
|
|
|
|
|
|
private <T> void convert(Map<String, Object> map, EntityWrapper<T> wrapper) {
|
for (Map.Entry<String, Object> entry : map.entrySet()) {
|
String val = String.valueOf(entry.getValue());
|
if (val.contains(RANGE_TIME_LINK)) {
|
String[] dates = val.split(RANGE_TIME_LINK);
|
wrapper.ge(entry.getKey(), DateUtils.convert(dates[0]));
|
wrapper.le(entry.getKey(), DateUtils.convert(dates[1]));
|
} else {
|
wrapper.like(entry.getKey(), val);
|
}
|
}
|
}
|
|
|
|
|
}
|