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