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