| 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.WrkMast; | 
| import com.zy.asrs.common.wms.service.WrkMastService; | 
| 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 WrkMastController extends BaseController { | 
|   | 
|     @Autowired | 
|     private WrkMastService wrkMastService; | 
|   | 
|     @RequestMapping(value = "/wrkMast/{id}/auth") | 
|     @ManagerAuth | 
|     public R get(@PathVariable("id") String id) { | 
|         return R.ok(wrkMastService.getById(String.valueOf(id))); | 
|     } | 
|   | 
|     @RequestMapping(value = "/wrkMast/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<WrkMast> wrapper = new LambdaQueryWrapper<>(); | 
|         wrapper.eq(WrkMast::getHostId, getHostId()); | 
|         if (!Cools.isEmpty(condition)) { | 
|             wrapper.like(WrkMast::getWrkNo, condition); | 
|         } | 
|         if (!Cools.isEmpty(timeRange)) { | 
|             String[] range = timeRange.split(RANGE_TIME_LINK); | 
|             wrapper.ge(WrkMast::getIoTime, DateUtils.convert(range[0])); | 
|             wrapper.le(WrkMast::getIoTime, DateUtils.convert(range[1])); | 
|         } | 
|         if (!Cools.isEmpty(param.get("wrk_no"))) { | 
|             wrapper.eq(WrkMast::getWrkNo, param.get("wrk_no")); | 
|         } | 
|         if (!Cools.isEmpty(param.get("wrk_sts"))) { | 
|             wrapper.eq(WrkMast::getWrkSts, param.get("wrk_sts")); | 
|         } | 
|         return R.ok(wrkMastService.page(new Page<>(curr, limit), wrapper)); | 
|     } | 
|   | 
|   | 
|     @RequestMapping(value = "/wrkMast/add/auth") | 
|     @ManagerAuth | 
|     public R add(WrkMast wrkMast) { | 
|         wrkMast.setHostId(getHostId()); | 
|         wrkMastService.save(wrkMast); | 
|         return R.ok(); | 
|     } | 
|   | 
|     @RequestMapping(value = "/wrkMast/update/auth") | 
|     @ManagerAuth | 
|     public R update(WrkMast wrkMast){ | 
|         if (Cools.isEmpty(wrkMast) || null==wrkMast.getId()){ | 
|             return R.error(); | 
|         } | 
|         wrkMastService.updateById(wrkMast); | 
|         return R.ok(); | 
|     } | 
|   | 
|     @RequestMapping(value = "/wrkMast/delete/auth") | 
|     @ManagerAuth | 
|     public R delete(@RequestParam(value="ids[]") Long[] ids){ | 
|          for (Long id : ids){ | 
|             wrkMastService.removeById(id); | 
|         } | 
|         return R.ok(); | 
|     } | 
|   | 
|     @RequestMapping(value = "/wrkMastQuery/auth") | 
|     @ManagerAuth | 
|     public R query(String condition) { | 
|         LambdaQueryWrapper<WrkMast> wrapper = new LambdaQueryWrapper<>(); | 
|         wrapper.eq(WrkMast::getHostId, getHostId()); | 
|         wrapper.like(WrkMast::getWrkNo, condition); | 
|         Page<WrkMast> page = wrkMastService.page(new Page<>(0, 10), wrapper); | 
|         List<Map<String, Object>> result = new ArrayList<>(); | 
|         for (WrkMast wrkMast : page.getRecords()){ | 
|             Map<String, Object> map = new HashMap<>(); | 
|             map.put("id", wrkMast.getId()); | 
|             map.put("value", wrkMast.getWrkNo()); | 
|             result.add(map); | 
|         } | 
|         return R.ok(result); | 
|     } | 
|   | 
|     @RequestMapping("/wrkMast/all/get/kv") | 
|     @ManagerAuth | 
|     public R getDataKV(@RequestParam(required = false) String condition) { | 
|         List<KeyValueVo> vos = new ArrayList<>(); | 
|         LambdaQueryWrapper<WrkMast> wrapper = new LambdaQueryWrapper<>(); | 
|         wrapper.eq(WrkMast::getHostId, getHostId()); | 
|         if (!Cools.isEmpty(condition)) { | 
|             wrapper.like(WrkMast::getWrkNo, condition); | 
|         } | 
|         wrkMastService.page(new Page<>(1, 30), wrapper).getRecords().forEach(item -> vos.add(new KeyValueVo(String.valueOf(item.getWrkNo()), item.getId()))); | 
|         return R.ok().add(vos); | 
|     } | 
|   | 
|     @RequestMapping(value = "/wrkMast/add/pri/auth") | 
|     @ManagerAuth(memo = "工作档增加优先级") | 
|     public R addPri(@RequestBody List<WrkMast> list) { | 
|         if (list.isEmpty()) { | 
|             return R.error("请至少选择一行数据"); | 
|         } | 
|         for (WrkMast entity : list){ | 
|             entity.setIoPri(entity.getIoPri() + 1); | 
|         } | 
|         wrkMastService.updateBatchById(list); | 
|         return R.ok(); | 
|     } | 
|   | 
|     @RequestMapping(value = "/wrkMast/red/pri/auth") | 
|     @ManagerAuth(memo = "工作档降低优先级") | 
|     public R redPri(@RequestBody List<WrkMast> list) { | 
|         if (list.isEmpty()) { | 
|             return R.error("请至少选择一行数据"); | 
|         } | 
|         for (WrkMast entity : list){ | 
|             entity.setIoPri(entity.getIoPri() - 1); | 
|         } | 
|         wrkMastService.updateBatchById(list); | 
|         return R.ok(); | 
|     } | 
|   | 
| } |