自动化立体仓库 - WMS系统
#
zjj
2025-03-14 dd984f63c67236c282d33ee45370d0424dadf5b5
src/main/java/com/zy/asrs/controller/NodeController.java
@@ -13,9 +13,12 @@
import com.core.common.DateUtils;
import com.core.common.R;
import com.core.exception.CoolException;
import com.zy.asrs.entity.BasWhs;
import com.zy.asrs.entity.LocMast;
import com.zy.asrs.entity.ManLocDetl;
import com.zy.asrs.entity.Node;
import com.zy.asrs.entity.param.InitPakoutParam;
import com.zy.asrs.entity.param.NodeLocInitParam;
import com.zy.asrs.entity.param.PakinParam;
import com.zy.asrs.entity.result.KeyValueVo;
import com.zy.asrs.mapper.ManLocDetlMapper;
@@ -23,6 +26,7 @@
import com.zy.common.entity.NodeExcel;
import com.zy.common.entity.NodeExcelListener;
import com.zy.common.entity.Parameter;
import com.zy.common.model.Shelves;
import com.zy.common.utils.ListUtils;
import com.zy.common.utils.NodeUtils;
import com.zy.common.utils.TreeUtils;
@@ -360,40 +364,84 @@
    @RequestMapping(value = "/node/init/auth")
    @ManagerAuth(memo = "平库库位初始化")
    @Transactional
    public R init(@RequestBody JSONObject param) {
        String area = param.getString("name");
        Integer value = param.getInteger("value");
        Integer num = param.getInteger("startRow");
        EntityWrapper<Node> nodeEntityWrapper = new EntityWrapper<>();
        nodeEntityWrapper.eq("id",value);
        nodeEntityWrapper.eq("name",area);
        Node node = nodeService.selectOne(nodeEntityWrapper);
        String[] string = node.getNamePath().split(",");
        for (int i = 1; i <= num; i++) {
            String locNo =area + String.format("%04d", i);
            String uuid = String.valueOf(System.currentTimeMillis());
            Date now =  new Date();
            Node node1 = new Node();
            node1.setUuid(uuid);
            node1.setName(locNo);
            node1.setParentId(node.getId());
            node1.setParentName(node.getName());
            node1.setType(3);
            node1.setPath(node.getPath()+","+node.getId());
            node1.setNamePath(node.getNamePath()+","+node.getName());
            node1.setLevel(3);
            node1.setStatus(1);
            node1.setCreateBy(getUserId());
            node1.setCreateTime(now);
            node1.setUpdateBy(getUserId());
            node1.setUpdateTime(now);
            if (!nodeService.insert(node1)){
                return R.error("数据插入失败");
            }
        }
//    @Transactional
    public R init(@RequestBody NodeLocInitParam param) {
        try{
            EntityWrapper<Node> nodeEntityWrapper = new EntityWrapper<>();
            nodeEntityWrapper.eq("id",param.getValue());
            nodeEntityWrapper.eq("name",param.getName());
            Node node = nodeService.selectOne(nodeEntityWrapper);
        return R.ok("初始化成功");
            if (!Cools.isEmpty(param.getEnable()) && param.getEnable() == 1){
                nodeService.delete(new EntityWrapper<Node>().eq("parent_id",node.getId()));
            }
            List<Node> 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++) {
                        char rowCode = (char)(64+r);
                        // 获取库位号
                        String locNo = String.format("%02d", param.getCode())+rowCode + String.format("%02d", b) + String.format("%02d", l);
                        String[] string = node.getNamePath().split(",");
                        String uuid = String.valueOf(System.currentTimeMillis());
                        Date now =  new Date();
                        Node node1 = new Node();
                        node1.setUuid(uuid);
                        node1.setName(locNo);
                        node1.setParentId(node.getId());
                        node1.setParentName(node.getName());
                        node1.setType(3);
                        node1.setPath(node.getPath()+","+node.getId());
                        node1.setNamePath(node.getNamePath()+","+node.getName());
                        node1.setLevel(3);
                        node1.setStatus(1);
                        node1.setCreateBy(getUserId());
                        node1.setCreateTime(now);
                        node1.setUpdateBy(getUserId());
                        node1.setUpdateTime(now);
                        nodeService.insert(node1);
                    }
                }
            }
            return R.ok("初始化成功");
        }catch (Exception e){
            return R.error("初始化失败===>"+e.getMessage());
        }
//        String area = param.getString("name");
//        Integer value = param.getInteger("value");
//        Integer num = param.getInteger("startRow");
//        EntityWrapper<Node> nodeEntityWrapper = new EntityWrapper<>();
//        nodeEntityWrapper.eq("id",value);
//        nodeEntityWrapper.eq("name",area);
//        Node node = nodeService.selectOne(nodeEntityWrapper);
//        String[] string = node.getNamePath().split(",");
//        for (int i = 1; i <= num; i++) {
//            String locNo =area + String.format("%04d", i);
//            String uuid = String.valueOf(System.currentTimeMillis());
//            Date now =  new Date();
//            Node node1 = new Node();
//            node1.setUuid(uuid);
//            node1.setName(locNo);
//            node1.setParentId(node.getId());
//            node1.setParentName(node.getName());
//            node1.setType(3);
//            node1.setPath(node.getPath()+","+node.getId());
//            node1.setNamePath(node.getNamePath()+","+node.getName());
//            node1.setLevel(3);
//            node1.setStatus(1);
//            node1.setCreateBy(getUserId());
//            node1.setCreateTime(now);
//            node1.setUpdateBy(getUserId());
//            node1.setUpdateTime(now);
//            if (!nodeService.insert(node1)){
//                return R.error("数据插入失败");
//            }
//        }
    }
}