package com.zy.asrs.wms.controller;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.zy.asrs.common.wms.entity.BasLocSts;
|
import com.zy.asrs.common.wms.entity.BasWrkIotype;
|
import com.zy.asrs.common.wms.service.BasWrkIotypeService;
|
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 BasWrkIotypeController extends BaseController {
|
|
@Autowired
|
private BasWrkIotypeService basWrkIotypeService;
|
|
@RequestMapping(value = "/basWrkIotype/{id}/auth")
|
@ManagerAuth
|
public R get(@PathVariable("id") String id) {
|
return R.ok(basWrkIotypeService.getById(String.valueOf(id)));
|
}
|
|
@RequestMapping(value = "/basWrkIotype/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<BasWrkIotype> wrapper = new LambdaQueryWrapper<>();
|
if (!Cools.isEmpty(condition)) {
|
wrapper.like(BasWrkIotype::getIoDesc, condition);
|
}
|
if (!Cools.isEmpty(timeRange)) {
|
String[] range = timeRange.split(RANGE_TIME_LINK);
|
wrapper.ge(BasWrkIotype::getAppeTime, DateUtils.convert(range[0]));
|
wrapper.le(BasWrkIotype::getAppeTime, DateUtils.convert(range[1]));
|
}
|
if (!Cools.isEmpty(param.get("io_type"))) {
|
wrapper.eq(BasWrkIotype::getIoType, param.get("io_type"));
|
}
|
return R.ok(basWrkIotypeService.page(new Page<>(curr, limit), wrapper));
|
}
|
|
|
@RequestMapping(value = "/basWrkIotype/add/auth")
|
@ManagerAuth
|
public R add(BasWrkIotype basWrkIotype) {
|
basWrkIotypeService.save(basWrkIotype);
|
return R.ok();
|
}
|
|
@RequestMapping(value = "/basWrkIotype/update/auth")
|
@ManagerAuth
|
public R update(BasWrkIotype basWrkIotype){
|
if (Cools.isEmpty(basWrkIotype) || null==basWrkIotype.getIoType()){
|
return R.error();
|
}
|
basWrkIotypeService.updateById(basWrkIotype);
|
return R.ok();
|
}
|
|
@RequestMapping(value = "/basWrkIotype/delete/auth")
|
@ManagerAuth
|
public R delete(@RequestParam(value="ids[]") Long[] ids){
|
for (Long id : ids){
|
basWrkIotypeService.removeById(id);
|
}
|
return R.ok();
|
}
|
|
@RequestMapping(value = "/basWrkIotypeQuery/auth")
|
@ManagerAuth
|
public R query(String condition) {
|
LambdaQueryWrapper<BasWrkIotype> wrapper = new LambdaQueryWrapper<>();
|
wrapper.like(BasWrkIotype::getIoDesc, condition);
|
Page<BasWrkIotype> page = basWrkIotypeService.page(new Page<>(0, 10), wrapper);
|
List<Map<String, Object>> result = new ArrayList<>();
|
for (BasWrkIotype basWrkIotype : page.getRecords()){
|
Map<String, Object> map = new HashMap<>();
|
map.put("id", basWrkIotype.getIoType());
|
map.put("value", basWrkIotype.getIoDesc());
|
result.add(map);
|
}
|
return R.ok(result);
|
}
|
|
@RequestMapping("/basWrkIotype/all/get/kv")
|
@ManagerAuth
|
public R getDataKV(@RequestParam(required = false) String condition) {
|
List<KeyValueVo> vos = new ArrayList<>();
|
LambdaQueryWrapper<BasWrkIotype> wrapper = new LambdaQueryWrapper<>();
|
if (!Cools.isEmpty(condition)) {
|
wrapper.like(BasWrkIotype::getIoDesc, condition);
|
}
|
basWrkIotypeService.page(new Page<>(1, 30), wrapper).getRecords().forEach(item -> vos.add(new KeyValueVo(String.valueOf(item.getIoDesc()), item.getIoType().longValue())));
|
return R.ok().add(vos);
|
}
|
|
}
|