#ZH
野心家
2025-05-26 3d40ce7e16a9e53bad6637bbed824507f06148b4
src/main/java/com/zy/asrs/controller/LocMastController.java
@@ -58,11 +58,43 @@
                  @RequestParam(required = false)String orderByField,
                  @RequestParam(required = false)String orderByType,
                  @RequestParam Map<String, Object> param){
        excludeTrash(param);
        EntityWrapper<LocMast> wrapper = new EntityWrapper<>();
        convert(param, wrapper);
        if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));}
        return R.ok(locMastService.selectPage(new Page<>(curr, limit), wrapper.eq("status",0)));
        try{
            String locNo = null;
            String locSts = null;
            long whsType = 0L;
            Integer crnNo = 0;
            Integer row1 = 0;
            Integer bay1 = 0;
            Integer lev1 = 0;
            for (Map.Entry<String, Object> entry : param.entrySet()) {
                String val = String.valueOf(entry.getValue());
                if (Cools.isEmpty(val)) {
                    continue;
                }
                if (entry.getKey().equals("whsType")) {
                    whsType = Long.getLong(val);
                }else if (entry.getKey().equals("loc_no")) {
                    locNo = val;
                }else if (entry.getKey().equals("crn_no")) {
                    crnNo = Integer.parseInt(val);
                }else if (entry.getKey().equals("row1")) {
                    row1 = Integer.parseInt(val);
                }else if (entry.getKey().equals("bay1")) {
                    bay1 = Integer.parseInt(val);
                }else if (entry.getKey().equals("lev1")) {
                    lev1 = Integer.parseInt(val);
                }else if (entry.getKey().equals("loc_sts")) {
                    locSts = val;
                }
            }
            List<LocMast> locMastList = locMastService.selectLocMastListSix(locSts,locNo,whsType,crnNo,row1,bay1,lev1,curr,limit);
            Page<LocMast> page = new Page<LocMast>(curr,limit).setRecords(locMastList);
            page.setTotal(locMastService.selectLocMastListTotalSix(locSts,locNo,whsType,crnNo,row1,bay1,lev1));
            return R.ok(page);
        }catch (Exception e){
            return R.error("异常" + e);
        }
    }
    private <T> void convert(Map<String, Object> map, EntityWrapper<T> wrapper){
@@ -116,15 +148,19 @@
    @RequestMapping(value = "/locMastQuery/auth")
    @ManagerAuth
    public R query(String condition) {
        EntityWrapper<LocMast> wrapper = new EntityWrapper<>();
        wrapper.like("loc_no", condition);
        Page<LocMast> page = locMastService.selectPage(new Page<>(0, 10), wrapper);
        List<LocMast> locMastList = locMastService.selectLocMastList(condition,0,10);
        Page<LocMast> page = new Page<LocMast>(0,10).setRecords(locMastList);
        page.setTotal(locMastService.selectLocMastListTotal(condition));
        List<Map<String, Object>> result = new ArrayList<>();
        for (LocMast locMast : page.getRecords()){
            Map<String, Object> map = new HashMap<>();
            map.put("id", locMast.getLocNo());
            map.put("value", locMast.getLocNo());
            result.add(map);
            if (!Cools.isEmpty(locMast)){
                Map<String, Object> map = new HashMap<>();
                map.put("id", locMast.getLocNo());
                map.put("value", locMast.getLocNo());
                result.add(map);
            }
        }
        return R.ok(result);
    }
@@ -154,6 +190,9 @@
                return R.error("容器编码或容器类型有误");
            }
        }
        if (locMast.getLocSts().equals("O")){
            locMast.setBarcode(null);
        }
        locMast.setModiUser(getUserId());
        locMast.setModiTime(new Date());
        locMastService.updateById(locMast);
@@ -161,6 +200,68 @@
        return R.ok();
    }
    @RequestMapping(value = "/locMast/init/auth2")
    @ManagerAuth(memo = "初始化库位")
//    @Transactional
    public R init2(LocMastInitParam param) {
        try{
            List<LocMast> list = new ArrayList<>();
            for (int r=param.getStartRow(); r<=param.getEndRow(); r++){
                for (int b=param.getStartBay(); b<=param.getEndBay(); b++) {
                    for (int l=param.getStartLev(); l<=param.getEndLev(); l++) {
                        // 获取库位号
                        String locNo = String.format("%02d", r) + String.format("%03d", b) + String.format("%02d", l);
                        // 获取堆垛机号
                        int crnNo = 0;
                        try{
                            Shelves shelves = new Shelves(param.getEndRow() - param.getStartRow() + 1, param.getCrnAmount(),param.getStartRow());
                            for (List<Integer> node : shelves.nodes){
                                if (node.contains(r)) {
                                    if (!Cools.isEmpty(param.getStaCrn()) && param.getStaCrn() > 0){
                                        crnNo = shelves.nodes.indexOf(node) + param.getStaCrn();
                                    }else {
                                        crnNo = shelves.nodes.indexOf(node) + 1;
                                    }
                                    break;
                                }
                            }
                        }catch (Exception e){
                            throw new Exception("解析堆垛机号失败,请填写正确的数据!!!");
                        }
                        Date now =  new Date();
                        LocMast locMast = new LocMast();
                        locMast.setLocNo(locNo);
                        locMast.setLocSts("O");
                        locMast.setRow1(r); // 排
                        locMast.setBay1(b); // 列
                        locMast.setLev1(l); // 层
//                        locMast.setGro1(r); // 组
                        locMast.setCrnNo(crnNo); // 堆垛机
                        locMast.setLocType1(!Cools.isEmpty(param.getLocType1()) ? param.getLocType1() : 1);
                        locMast.setLocType2(param.getLocType2());
                        locMast.setLocType3(param.getLocType3());
                        locMast.setAppeUser(getUserId());
                        locMast.setAppeTime(now);
                        locMast.setModiUser(getUserId());
                        locMast.setModiTime(now);
//                        locMast.setWhsType(basWhs.getId());
                        list.add(locMast);
                    }
                }
            }
            if (!Cools.isEmpty(param.getEnable()) && param.getEnable() == 1){
                locMastService.delete(new EntityWrapper<>());
            }
            locMastService.insertBatch(list);
            return R.ok("初始化成功");
        }catch (Exception e){
            return R.error("初始化失败===>"+e.getMessage());
        }
    }
    @RequestMapping(value = "/locMast/init/auth")
    @ManagerAuth(memo = "初始化库位")
//    @Transactional