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 param){ excludeTrash(param); EntityWrapper 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 plaQties = plaQtyService.selectList(new EntityWrapper().eq("order_no", orderNo).eq(false,"returned",1)); plaQties = plaQties.stream().filter(plaQty -> { ManPakOut manPakOut = manPakOutService.selectOne(new EntityWrapper().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 wrapper = new EntityWrapper<>(); wrapper.setSqlSelect("order_no"); wrapper.like("id", condition); wrapper.groupBy("order_no"); List list = plaQtyService.selectOrderNo(); List> result = new ArrayList<>(); for (String orderNo : list){ Map map = new HashMap<>(); PlaQty plaQty = plaQtyService.selectOne(new EntityWrapper().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 void convert(Map map, EntityWrapper wrapper){ for (Map.Entry 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); } } } }