package com.zy.asrs.wms.controller; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.zy.asrs.common.wms.entity.RowLastno; import com.zy.asrs.common.wms.service.RowLastnoService; import com.zy.asrs.framework.annotations.ManagerAuth; import com.zy.asrs.framework.common.Cools; import com.zy.asrs.framework.common.R; import com.zy.asrs.framework.domain.KeyValueVo; import com.zy.asrs.framework.common.DateUtils; import com.zy.asrs.common.web.BaseController; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.*; @RestController public class RowLastnoController extends BaseController { @Autowired private RowLastnoService rowLastnoService; @RequestMapping(value = "/rowLastno/{id}/auth") @ManagerAuth public R get(@PathVariable("id") Long id) { return R.ok(rowLastnoService.getById(id)); } @RequestMapping(value = "/rowLastno/page/auth") @ManagerAuth public R page(@RequestParam(defaultValue = "1") Integer curr, @RequestParam(defaultValue = "10") Integer limit, @RequestParam(required = false) String condition, @RequestParam(required = false) String timeRange, @RequestParam Map param) { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(RowLastno::getHostId, getHostId()); if (!Cools.isEmpty(condition)) { wrapper.like(RowLastno::getWhsType, condition); } if (!Cools.isEmpty(timeRange)) { String[] range = timeRange.split(RANGE_TIME_LINK); wrapper.ge(RowLastno::getAppeTime, DateUtils.convert(range[0])); wrapper.le(RowLastno::getAppeTime, DateUtils.convert(range[1])); } return R.ok(rowLastnoService.page(new Page<>(curr, limit), wrapper)); } @RequestMapping(value = "/rowLastno/add/auth") @ManagerAuth public R add(RowLastno rowLastno) { rowLastno.setHostId(getHostId()); rowLastnoService.save(rowLastno); return R.ok(); } @RequestMapping(value = "/rowLastno/update/auth") @ManagerAuth public R update(RowLastno rowLastno){ if (Cools.isEmpty(rowLastno) || null==rowLastno.getWhsType()){ return R.error(); } rowLastnoService.updateById(rowLastno); return R.ok(); } @RequestMapping(value = "/rowLastno/delete/auth") @ManagerAuth public R delete(@RequestParam(value="ids[]") Long[] ids){ for (Long id : ids){ rowLastnoService.removeById(id); } return R.ok(); } @RequestMapping(value = "/rowLastnoQuery/auth") @ManagerAuth public R query(String condition) { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(RowLastno::getHostId, getHostId()); wrapper.like(RowLastno::getWhsType, condition); Page page = rowLastnoService.page(new Page<>(0, 10), wrapper); List> result = new ArrayList<>(); for (RowLastno rowLastno : page.getRecords()){ Map map = new HashMap<>(); map.put("id", rowLastno.getWhsType()); map.put("value", rowLastno.getWhsType()); result.add(map); } return R.ok(result); } @RequestMapping("/rowLastno/all/get/kv") @ManagerAuth public R getDataKV(@RequestParam(required = false) String condition) { List vos = new ArrayList<>(); LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(RowLastno::getHostId, getHostId()); if (!Cools.isEmpty(condition)) { wrapper.like(RowLastno::getWhsType, condition); } rowLastnoService.page(new Page<>(1, 30), wrapper).getRecords().forEach(item -> vos.add(new KeyValueVo(String.valueOf(item.getWhsType()), item.getWhsType().longValue()))); return R.ok().add(vos); } }