|  |  | 
 |  |  |  | 
 |  |  | import com.alibaba.fastjson.JSONArray; | 
 |  |  | 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.utils.TreeUtils; | 
 |  |  | import com.zy.asrs.common.wms.entity.Mat; | 
 |  |  | 
 |  |  |                   @RequestParam(required = false) String condition, | 
 |  |  |                   @RequestParam(required = false) String timeRange, | 
 |  |  |                   @RequestParam Map<String, Object> param) { | 
 |  |  |         LambdaQueryWrapper<Mat> wrapper = new LambdaQueryWrapper<>(); | 
 |  |  |         wrapper.eq(Mat::getHostId, getHostId()); | 
 |  |  |         if (!Cools.isEmpty(condition)) { | 
 |  |  |             wrapper.like(Mat::getId, condition); | 
 |  |  |         } | 
 |  |  |         QueryWrapper<Mat> wrapper = new QueryWrapper<>(); | 
 |  |  | //        convert(param, wrapper); | 
 |  |  |         wrapper.eq("host_id", getHostId()); | 
 |  |  | //        if (!Cools.isEmpty(condition)) { | 
 |  |  | //            wrapper.like(Mat::getId, condition); | 
 |  |  | //        } | 
 |  |  |         if (!Cools.isEmpty(timeRange)) { | 
 |  |  |             String[] range = timeRange.split(RANGE_TIME_LINK); | 
 |  |  |             wrapper.ge(Mat::getCreateTime, DateUtils.convert(range[0])); | 
 |  |  |             wrapper.le(Mat::getCreateTime, DateUtils.convert(range[1])); | 
 |  |  |             wrapper.ge("create_time", DateUtils.convert(range[0])); | 
 |  |  |             wrapper.le("create_time", DateUtils.convert(range[1])); | 
 |  |  |         } | 
 |  |  |         Object tagId = param.get("tag_id"); | 
 |  |  |         ArrayList<Long> nodes = new ArrayList<>(); | 
 |  |  | 
 |  |  |             tagId = getOriginTag().getId(); | 
 |  |  |         } | 
 |  |  |         treeUtils.getTagIdList(Long.parseLong(tagId.toString()), nodes); | 
 |  |  |         wrapper.in(Mat::getTagId, nodes); | 
 |  |  |         wrapper.in("tag_id", nodes); | 
 |  |  |         if (!Cools.isEmpty(param.get("matnr"))) { | 
 |  |  |             wrapper.eq(Mat::getMatnr, param.get("matnr")); | 
 |  |  |             wrapper.eq("matnr", param.get("matnr")); | 
 |  |  |         } | 
 |  |  |         if (!Cools.isEmpty(param.get("maktx"))) { | 
 |  |  |             wrapper.eq(Mat::getMaktx, param.get("maktx")); | 
 |  |  |             wrapper.eq("maktx", param.get("maktx")); | 
 |  |  |         } | 
 |  |  |         if (!Cools.isEmpty(param.get("decrees"))) { | 
 |  |  |             wrapper.eq("decrees", param.get("decrees")); | 
 |  |  |         } | 
 |  |  | //        if (!Cools.isEmpty(param.get("owner$"))) { | 
 |  |  | //            wrapper.eq("owner", param.get("owner$")); | 
 |  |  | //        } | 
 |  |  |         param.remove("matnr"); | 
 |  |  |         param.remove("maktx"); | 
 |  |  |         param.remove("decrees"); | 
 |  |  | //        param.remove("owner$"); | 
 |  |  |         allLike(Mat.class, param.keySet(), wrapper, condition); | 
 |  |  |         return R.ok(matService.page(new Page<>(curr, limit), wrapper)); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  | //    private <T> void convert(Map<String, Object> map, QueryWrapper<T> wrapper){ | 
 |  |  | //        for (Map.Entry<String, Object> entry : map.entrySet()){ | 
 |  |  | //            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 = "/mat/add/auth") | 
 |  |  |     @ManagerAuth | 
 |  |  |     public R add(Mat mat) { | 
 |  |  |         int count = matService.count(new LambdaQueryWrapper<Mat>().eq(Mat::getMatnr, mat.getMatnr())); | 
 |  |  |         if(count > 0){ | 
 |  |  |             return R.error("当前物料号已存在"); | 
 |  |  |         } | 
 |  |  |         mat.setHostId(getHostId()); | 
 |  |  |         matService.save(mat); | 
 |  |  |         return R.ok(); |