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