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