package com.zy.asrs.controller;
|
|
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
import com.baomidou.mybatisplus.plugins.Page;
|
import com.core.annotations.ManagerAuth;
|
import com.core.common.Cools;
|
import com.core.common.DateUtils;
|
import com.core.common.R;
|
import com.zy.asrs.entity.ManPakOut;
|
import com.zy.asrs.entity.PlaQty;
|
import com.zy.asrs.service.ManPakOutService;
|
import com.zy.asrs.service.PlaQtyService;
|
import com.zy.asrs.service.PlaService;
|
import com.zy.common.web.BaseController;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RestController;
|
|
import java.util.*;
|
import java.util.stream.Collectors;
|
|
@RestController
|
public class PlaQtyController extends BaseController {
|
|
@Autowired
|
private PlaService plaService;
|
@Autowired
|
private PlaQtyService plaQtyService;
|
@Autowired
|
private ManPakOutService manPakOutService;
|
|
@RequestMapping(value = "/plaQty/list/auth")
|
@ManagerAuth
|
public R list(@RequestParam(defaultValue = "1")Integer curr,
|
@RequestParam(defaultValue = "10")Integer limit,
|
@RequestParam(required = false)String condition,
|
@RequestParam Map<String, Object> param){
|
excludeTrash(param);
|
EntityWrapper<PlaQty> wrapper = new EntityWrapper<>();
|
convert(param, wrapper);
|
allLike(PlaQty.class, param.keySet(), wrapper, condition);
|
return R.ok(plaQtyService.selectPage(new Page<>(curr, limit), wrapper));
|
}
|
|
@RequestMapping(value = "/plaQty/orderDetail/auth")
|
@ManagerAuth
|
public R getOrderDetail(String orderNo) {
|
|
List<PlaQty> plaQties = plaQtyService.selectList(new EntityWrapper<PlaQty>().eq("order_no", orderNo).eq(false,"returned",1));
|
|
plaQties = plaQties.stream().filter(plaQty -> {
|
ManPakOut manPakOut = manPakOutService.selectOne(new EntityWrapper<ManPakOut>().eq("node_id", plaQty.getId()));
|
if (Cools.isEmpty(manPakOut)) {
|
return false;
|
}
|
if (Cools.isEmpty(manPakOut.getStatus()) || manPakOut.getStatus() != 1) {
|
return false;
|
}
|
if(plaQty.getReturned() > 0){
|
return false;
|
}
|
|
return true;
|
}).collect(Collectors.toList());
|
|
|
return R.ok(plaQties);
|
}
|
|
@RequestMapping(value = "/plaQty/delivery/auth")
|
@ManagerAuth
|
public R delivery() {
|
return R.ok(plaQtyService.getDeliveryDate());
|
}
|
|
@RequestMapping(value = "/orderNoQuery/auth")
|
@ManagerAuth
|
public R query(String condition) {
|
// EntityWrapper<PlaQty> wrapper = new EntityWrapper<>();
|
// wrapper.setSqlSelect("order_no");
|
// wrapper.like("order_no", Cools.isEmpty(condition) ? "0" : condition);
|
// wrapper.groupBy("order_no");
|
// Page<PlaQty> plaQtyPage = plaQtyService.selectPage(new Page<>(1, 20), wrapper);
|
List<String> list = plaQtyService.selectOrderNo(Cools.isEmpty(condition) ? "0" : condition);
|
List<Map<String, Object>> result = new ArrayList<>();
|
for (String orderNo : list){
|
Map<String, Object> map = new HashMap<>();
|
PlaQty plaQty = plaQtyService.selectOne(new EntityWrapper<PlaQty>().eq("order_no", orderNo));
|
map.put("id", plaQty.getId());
|
map.put("value", orderNo);
|
map.put("customer", plaQty.getCustomer());
|
map.put("type","returned");
|
result.add(map);
|
}
|
return R.ok(result);
|
}
|
|
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.eq(entry.getKey(), val);
|
}
|
}
|
}
|
|
}
|