package com.zy.asrs.controller;
|
|
import com.alibaba.fastjson.JSONObject;
|
import com.baomidou.mybatisplus.plugins.Page;
|
import com.core.annotations.ManagerAuth;
|
import com.core.common.R;
|
import com.zy.asrs.entity.OrderDetlPakoutLog;
|
import com.zy.asrs.entity.OrderPakoutLog;
|
import com.zy.asrs.service.OrderDetlPakoutLogService;
|
import com.zy.asrs.service.OrderPakoutLogService;
|
import com.zy.common.web.BaseController;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RestController;
|
|
import java.util.List;
|
import java.util.Map;
|
|
@RestController
|
@RequestMapping("order/pakout/history")
|
public class OrderPakoutLogController extends BaseController {
|
|
@Autowired
|
private OrderPakoutLogService orderPakoutLogService;
|
@Autowired
|
private OrderDetlPakoutLogService orderDetlPakoutLogService;
|
|
@RequestMapping(value = "/order/list/auth")
|
@ManagerAuth(memo = "出库单据历史档查询")
|
public R list(@RequestParam(defaultValue = "1") Integer curr,
|
@RequestParam(defaultValue = "10") Integer limit,
|
@RequestParam Map<String, Object> param) {
|
excludeTrash(param);
|
normalizeRange(param, "create_time", "createTimeStart", "createTimeEnd");
|
normalizeRange(param, "update_time", "updateTimeStart", "updateTimeEnd");
|
return R.ok(orderPakoutLogService.selectHistoryPage(toSimplePage(curr, limit, param)));
|
}
|
|
@RequestMapping(value = "/orderDetl/list/auth")
|
@ManagerAuth(memo = "出库单据历史明细查询")
|
public R detlList(@RequestParam(defaultValue = "1") Integer curr,
|
@RequestParam(defaultValue = "10") Integer limit,
|
@RequestParam Map<String, Object> param) {
|
excludeTrash(param);
|
return R.ok(orderDetlPakoutLogService.selectHistoryPage(toSimplePage(curr, limit, param)));
|
}
|
|
@RequestMapping(value = "/order/export/auth")
|
@ManagerAuth(memo = "出库单据历史档导出")
|
public R export(@RequestBody JSONObject param) {
|
List<String> fields = JSONObject.parseArray(param.getJSONArray("fields").toJSONString(), String.class);
|
Map<String, Object> map = excludeTrash(param.getJSONObject("orderPakoutLog"));
|
normalizeRange(map, "create_time", "createTimeStart", "createTimeEnd");
|
normalizeRange(map, "update_time", "updateTimeStart", "updateTimeEnd");
|
List<OrderPakoutLog> list = orderPakoutLogService.selectHistoryAll(map);
|
return R.ok(exportSupport(list, fields));
|
}
|
|
private void normalizeRange(Map<String, Object> param, String sourceKey, String startKey, String endKey) {
|
Object rangeObj = param.remove(sourceKey);
|
if (rangeObj == null) {
|
return;
|
}
|
String range = String.valueOf(rangeObj);
|
if (!range.contains(RANGE_TIME_LINK)) {
|
param.put(sourceKey, range);
|
return;
|
}
|
String[] dates = range.split(RANGE_TIME_LINK);
|
if (dates.length > 0) {
|
param.put(startKey, dates[0]);
|
}
|
if (dates.length > 1) {
|
param.put(endKey, dates[1]);
|
}
|
}
|
|
private <T> Page<T> toSimplePage(Integer pageNumber, Integer pageSize, Map<String, Object> map) {
|
Page<T> page = new Page<>(pageNumber, pageSize);
|
map.put("pageNumber", pageNumber);
|
map.put("pageSize", pageSize);
|
page.setCondition(map);
|
return page;
|
}
|
}
|