|  |  |  | 
|---|
|  |  |  | 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.web.BaseController; | 
|---|
|  |  |  | import com.zy.asrs.common.wms.entity.WrkDetl; | 
|---|
|  |  |  | import com.zy.asrs.common.wms.service.WrkDetlService; | 
|---|
|  |  |  | import com.zy.asrs.framework.annotations.ManagerAuth; | 
|---|
|  |  |  | import com.zy.asrs.framework.common.Cools; | 
|---|
|  |  |  | import com.zy.asrs.framework.common.DateUtils; | 
|---|
|  |  |  | 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 org.springframework.web.bind.annotation.PathVariable; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.RequestMapping; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.RequestParam; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.RestController; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.*; | 
|---|
|  |  |  | import java.util.ArrayList; | 
|---|
|  |  |  | import java.util.HashMap; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | import java.util.Map; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RestController | 
|---|
|  |  |  | public class WrkDetlController extends BaseController { | 
|---|
|  |  |  | 
|---|
|  |  |  | @RequestParam(required = false) String condition, | 
|---|
|  |  |  | @RequestParam(required = false) String timeRange, | 
|---|
|  |  |  | @RequestParam Map<String, Object> param) { | 
|---|
|  |  |  | LambdaQueryWrapper<WrkDetl> wrapper = new LambdaQueryWrapper<>(); | 
|---|
|  |  |  | wrapper.eq(WrkDetl::getHostId, getHostId()); | 
|---|
|  |  |  | if (!Cools.isEmpty(condition)) { | 
|---|
|  |  |  | wrapper.like(WrkDetl::getId, condition); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | QueryWrapper<WrkDetl> wrapper = new QueryWrapper<>(); | 
|---|
|  |  |  | wrapper.eq("host_id", getHostId()); | 
|---|
|  |  |  | //        if (!Cools.isEmpty(condition)) { | 
|---|
|  |  |  | //            wrapper.like(WrkDetl::getId, condition); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | if (!Cools.isEmpty(timeRange)) { | 
|---|
|  |  |  | String[] range = timeRange.split(RANGE_TIME_LINK); | 
|---|
|  |  |  | wrapper.ge(WrkDetl::getAppeTime, DateUtils.convert(range[0])); | 
|---|
|  |  |  | wrapper.le(WrkDetl::getAppeTime, DateUtils.convert(range[1])); | 
|---|
|  |  |  | wrapper.ge("io_time", DateUtils.convert(range[0])); | 
|---|
|  |  |  | wrapper.le("io_time", DateUtils.convert(range[1])); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!Cools.isEmpty(param.get("wrk_mast_id"))) { | 
|---|
|  |  |  | wrapper.eq(WrkDetl::getWrkMastId, param.get("wrk_mast_id")); | 
|---|
|  |  |  | wrapper.eq("wrk_mast_id", param.get("wrk_mast_id")); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!Cools.isEmpty(param.get("matnr"))) { | 
|---|
|  |  |  | wrapper.like(WrkDetl::getMatnr, param.get("matnr")); | 
|---|
|  |  |  | wrapper.like("matnr", param.get("matnr")); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!Cools.isEmpty(param.get("maktx"))) { | 
|---|
|  |  |  | wrapper.like(WrkDetl::getMaktx, param.get("maktx")); | 
|---|
|  |  |  | wrapper.like("maktx", param.get("maktx")); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!Cools.isEmpty(param.get("zpallet"))) { | 
|---|
|  |  |  | wrapper.like("zpallet", param.get("zpallet")); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!Cools.isEmpty(param.get("orderNo"))) { | 
|---|
|  |  |  | wrapper.like("order_no", param.get("orderNo")); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | allLike(WrkDetl.class, param.keySet(), wrapper, condition); | 
|---|
|  |  |  | wrapper.orderByDesc("io_time"); | 
|---|
|  |  |  | return R.ok(wrkDetlService.page(new Page<>(curr, limit), wrapper)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | return R.ok(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping(value = "/wrkDetl/update/auth") | 
|---|
|  |  |  | @ManagerAuth | 
|---|
|  |  |  | public R update(WrkDetl wrkDetl){ | 
|---|
|  |  |  | if (Cools.isEmpty(wrkDetl) || null==wrkDetl.getId()){ | 
|---|
|  |  |  | @RequestMapping(value = "/wrkDetl/update/auth") | 
|---|
|  |  |  | @ManagerAuth | 
|---|
|  |  |  | public R update(WrkDetl wrkDetl) { | 
|---|
|  |  |  | if (Cools.isEmpty(wrkDetl) || null == wrkDetl.getId()) { | 
|---|
|  |  |  | return R.error(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | wrkDetlService.updateById(wrkDetl); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping(value = "/wrkDetl/delete/auth") | 
|---|
|  |  |  | @ManagerAuth | 
|---|
|  |  |  | public R delete(@RequestParam(value="ids[]") Long[] ids){ | 
|---|
|  |  |  | for (Long id : ids){ | 
|---|
|  |  |  | public R delete(@RequestParam(value = "ids[]") Long[] ids) { | 
|---|
|  |  |  | for (Long id : ids) { | 
|---|
|  |  |  | wrkDetlService.removeById(id); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok(); | 
|---|
|  |  |  | 
|---|
|  |  |  | wrapper.like(WrkDetl::getId, condition); | 
|---|
|  |  |  | Page<WrkDetl> page = wrkDetlService.page(new Page<>(0, 10), wrapper); | 
|---|
|  |  |  | List<Map<String, Object>> result = new ArrayList<>(); | 
|---|
|  |  |  | for (WrkDetl wrkDetl : page.getRecords()){ | 
|---|
|  |  |  | for (WrkDetl wrkDetl : page.getRecords()) { | 
|---|
|  |  |  | Map<String, Object> map = new HashMap<>(); | 
|---|
|  |  |  | map.put("id", wrkDetl.getId()); | 
|---|
|  |  |  | map.put("value", wrkDetl.getId()); | 
|---|