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.BasWhs;
|
import com.zy.asrs.common.wms.service.BasWhsService;
|
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 BasWhsController extends BaseController {
|
|
@Autowired
|
private BasWhsService basWhsService;
|
|
@RequestMapping(value = "/basWhs/{id}/auth")
|
@ManagerAuth
|
public R get(@PathVariable("id") String id) {
|
return R.ok(basWhsService.getById(String.valueOf(id)));
|
}
|
|
@RequestMapping(value = "/basWhs/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<String, Object> param) {
|
LambdaQueryWrapper<BasWhs> wrapper = new LambdaQueryWrapper<>();
|
if (!Cools.isEmpty(condition)) {
|
wrapper.like(BasWhs::getWhsDesc, condition);
|
}
|
if (!Cools.isEmpty(timeRange)) {
|
String[] range = timeRange.split(RANGE_TIME_LINK);
|
wrapper.ge(BasWhs::getAppeTime, DateUtils.convert(range[0]));
|
wrapper.le(BasWhs::getAppeTime, DateUtils.convert(range[1]));
|
}
|
return R.ok(basWhsService.page(new Page<>(curr, limit), wrapper));
|
}
|
|
|
@RequestMapping(value = "/basWhs/add/auth")
|
@ManagerAuth
|
public R add(BasWhs basWhs) {
|
basWhsService.save(basWhs);
|
return R.ok();
|
}
|
|
@RequestMapping(value = "/basWhs/update/auth")
|
@ManagerAuth
|
public R update(BasWhs basWhs){
|
if (Cools.isEmpty(basWhs) || null==basWhs.getId()){
|
return R.error();
|
}
|
basWhsService.updateById(basWhs);
|
return R.ok();
|
}
|
|
@RequestMapping(value = "/basWhs/delete/auth")
|
@ManagerAuth
|
public R delete(@RequestParam(value="ids[]") Long[] ids){
|
for (Long id : ids){
|
basWhsService.removeById(id);
|
}
|
return R.ok();
|
}
|
|
@RequestMapping(value = "/basWhsQuery/auth")
|
@ManagerAuth
|
public R query(String condition) {
|
LambdaQueryWrapper<BasWhs> wrapper = new LambdaQueryWrapper<>();
|
wrapper.like(BasWhs::getWhsDesc, condition);
|
Page<BasWhs> page = basWhsService.page(new Page<>(0, 10), wrapper);
|
List<Map<String, Object>> result = new ArrayList<>();
|
for (BasWhs basWhs : page.getRecords()){
|
Map<String, Object> map = new HashMap<>();
|
map.put("id", basWhs.getId());
|
map.put("value", basWhs.getWhsDesc());
|
result.add(map);
|
}
|
return R.ok(result);
|
}
|
|
@RequestMapping("/basWhs/all/get/kv")
|
@ManagerAuth
|
public R getDataKV(@RequestParam(required = false) String condition) {
|
List<KeyValueVo> vos = new ArrayList<>();
|
LambdaQueryWrapper<BasWhs> wrapper = new LambdaQueryWrapper<>();
|
if (!Cools.isEmpty(condition)) {
|
wrapper.like(BasWhs::getWhsDesc, condition);
|
}
|
basWhsService.page(new Page<>(1, 30), wrapper).getRecords().forEach(item -> vos.add(new KeyValueVo(String.valueOf(item.getWhsDesc()), item.getId())));
|
return R.ok().add(vos);
|
}
|
|
}
|