| 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.core.conditions.query.QueryWrapper; | 
| import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | 
| import com.zy.asrs.common.wms.entity.LocDetl; | 
| import com.zy.asrs.common.wms.entity.WaitPakin; | 
| import com.zy.asrs.common.wms.entity.WaitPakinLog; | 
| import com.zy.asrs.common.wms.service.WaitPakinLogService; | 
| 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 WaitPakinLogController extends BaseController { | 
|   | 
|     @Autowired | 
|     private WaitPakinLogService waitPakinLogService; | 
|   | 
|     @RequestMapping(value = "/waitPakinLog/{id}/auth") | 
|     @ManagerAuth | 
|     public R get(@PathVariable("id") String id) { | 
|         return R.ok(waitPakinLogService.getById(String.valueOf(id))); | 
|     } | 
|   | 
|     @RequestMapping(value = "/waitPakinLog/export/auth1") | 
|     @ManagerAuth(memo = "库位明细导出") | 
|     public synchronized R export(@RequestBody JSONObject param){ | 
|         List<String> fields = JSONObject.parseArray(param.getJSONArray("fields").toJSONString(), String.class); | 
|         QueryWrapper<WaitPakinLog> wrapper = new QueryWrapper<>(); | 
|         Map<String, Object> map = excludeTrash(param.getJSONObject("waitPakinLog")); | 
|         String row = ""; | 
|         if (map.get("row") != null) { | 
|             String chooseRow = (String) map.get("row"); | 
|             if (chooseRow.length() == 1) { | 
|                 row = "0" + chooseRow; | 
|                 map.remove("row"); | 
|             }else { | 
|                 row = chooseRow; | 
|                 map.remove("row"); | 
|             } | 
|         } | 
|         convert(map, wrapper); | 
| //        if (!row.equals("")){ | 
| //            wrapper.and() | 
| //                    .where("loc_no like '" +row +"%'"); | 
| //        } | 
|         List<WaitPakinLog> list = waitPakinLogService.list(wrapper); | 
|         return R.ok(exportSupport(list, fields)); | 
|     } | 
|     private <T> void convert(Map<String, Object> map, QueryWrapper<T> wrapper){ | 
|         for (Map.Entry<String, Object> entry : map.entrySet()){ | 
|             if(Cools.eq(entry.getKey(),"curr") | 
|                     || Cools.eq(entry.getKey(),"limit") | 
|                     || Cools.eq(entry.getKey(),"unreason") | 
|                     || Cools.eq(entry.getKey(),"orderByField") | 
|                     || Cools.eq(entry.getKey(),"orderByType") | 
|                     || Cools.eq(entry.getKey(),"row") | 
|                     || Cools.eq(entry.getKey(),"condition")){ | 
|                 continue; | 
|             } | 
|   | 
|             if(Cools.isEmpty(entry.getValue())){ | 
|                 continue; | 
|             } | 
|   | 
|             String val = String.valueOf(entry.getValue()); | 
|             if (val.contains(RANGE_TIME_LINK)){ | 
|                 String[] dates = val.split(RANGE_TIME_LINK); | 
|                 wrapper.ge(entry.getKey(), DateUtils.convert(dates[0])); | 
|                 wrapper.le(entry.getKey(), DateUtils.convert(dates[1])); | 
|             } else { | 
|                 if (entry.getKey().equals("locNo")) { | 
|                     wrapper.eq("loc_no", String.valueOf(entry.getValue())); | 
|                 } else { | 
|                     wrapper.like(entry.getKey(), String.valueOf(entry.getValue())); | 
|                 } | 
|             } | 
|         } | 
|     } | 
|   | 
|   | 
|     @RequestMapping(value = "/waitPakinLog/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<WaitPakinLog> wrapper = new LambdaQueryWrapper<>(); | 
|         wrapper.eq(WaitPakinLog::getHostId, getHostId()); | 
|         if (!Cools.isEmpty(timeRange)) { | 
|             String[] range = timeRange.split(RANGE_TIME_LINK); | 
|             wrapper.ge(WaitPakinLog::getAppeTime, DateUtils.convert(range[0])); | 
|             wrapper.le(WaitPakinLog::getAppeTime, DateUtils.convert(range[1])); | 
|         } | 
|         if (!Cools.isEmpty(param.get("zpallet"))) { | 
|             wrapper.like(WaitPakinLog::getZpallet, param.get("zpallet")); | 
|         } | 
|         if (!Cools.isEmpty(param.get("matnr"))) { | 
|             wrapper.like(WaitPakinLog::getMatnr, param.get("matnr")); | 
|         } | 
|         return R.ok(waitPakinLogService.page(new Page<>(curr, limit), wrapper)); | 
|     } | 
|   | 
|   | 
|     @RequestMapping(value = "/waitPakinLog/add/auth") | 
|     @ManagerAuth | 
|     public R add(WaitPakinLog waitPakinLog) { | 
|         waitPakinLogService.save(waitPakinLog); | 
|         return R.ok(); | 
|     } | 
|   | 
|     @RequestMapping(value = "/waitPakinLog/update/auth") | 
|     @ManagerAuth | 
|     public R update(WaitPakinLog waitPakinLog){ | 
|         if (Cools.isEmpty(waitPakinLog) || null==waitPakinLog.getId()){ | 
|             return R.error(); | 
|         } | 
|         waitPakinLogService.updateById(waitPakinLog); | 
|         return R.ok(); | 
|     } | 
|   | 
|     @RequestMapping(value = "/waitPakinLog/delete/auth") | 
|     @ManagerAuth | 
|     public R delete(@RequestParam(value="ids[]") Long[] ids){ | 
|          for (Long id : ids){ | 
|             waitPakinLogService.removeById(id); | 
|         } | 
|         return R.ok(); | 
|     } | 
|   | 
|     @RequestMapping(value = "/waitPakinLogQuery/auth") | 
|     @ManagerAuth | 
|     public R query(String condition) { | 
|         LambdaQueryWrapper<WaitPakinLog> wrapper = new LambdaQueryWrapper<>(); | 
|         wrapper.like(WaitPakinLog::getId, condition); | 
|         Page<WaitPakinLog> page = waitPakinLogService.page(new Page<>(0, 10), wrapper); | 
|         List<Map<String, Object>> result = new ArrayList<>(); | 
|         for (WaitPakinLog waitPakinLog : page.getRecords()){ | 
|             Map<String, Object> map = new HashMap<>(); | 
|             map.put("id", waitPakinLog.getId()); | 
|             map.put("value", waitPakinLog.getId()); | 
|             result.add(map); | 
|         } | 
|         return R.ok(result); | 
|     } | 
|   | 
|     @RequestMapping("/waitPakinLog/all/get/kv") | 
|     @ManagerAuth | 
|     public R getDataKV(@RequestParam(required = false) String condition) { | 
|         List<KeyValueVo> vos = new ArrayList<>(); | 
|         LambdaQueryWrapper<WaitPakinLog> wrapper = new LambdaQueryWrapper<>(); | 
|         if (!Cools.isEmpty(condition)) { | 
|             wrapper.like(WaitPakinLog::getId, condition); | 
|         } | 
|         waitPakinLogService.page(new Page<>(1, 30), wrapper).getRecords().forEach(item -> vos.add(new KeyValueVo(String.valueOf(item.getId()), item.getId()))); | 
|         return R.ok().add(vos); | 
|     } | 
|   | 
| } |