自动化立体仓库 - WMS系统
cl
16 小时以前 1104f7c6dbf4a1c6c9d47abf75f9b39ce1f3a5f7
src/main/java/com/zy/asrs/controller/OpenController.java
@@ -57,6 +57,8 @@
    private MatService matService;
    @Autowired
    private LocMastService locMastService;
    @Autowired
    private ReportQueryMapper reportQueryMapper;
//    @PostMapping("/order/matSync/default/v1")
////    @AppAuth(memo = "商品信息同步接口")
@@ -151,6 +153,7 @@
    private void auth(String appkey, Object obj, HttpServletRequest request) {
        log.info("{}接口被访问;appkey:{};请求数据:{}", "open/sensorType/list/auth/v1", appkey, JSON.toJSONString(obj));
        log.info("[auth] cache: {}", obj == null ? "null" : JSON.toJSONString(obj));
        request.setAttribute("cache", obj);
        if (!auth) {
            return;
@@ -396,8 +399,12 @@
    @PostMapping("/order/matSync/default/v2")
//    @AppAuth(memo = "商品信息同步接口")
    public synchronized R syncMatInfoV2(@RequestBody(required = false) List<MatSyncParam.MatParam> param){
    public synchronized R syncMatInfoV2(@RequestBody(required = false) List<MatSyncParam.MatParam> param,
                                        HttpServletRequest request) {
        if (request != null) {
            log.info("[syncMatInfoV2] cache: {}", param == null ? "null" : JSON.toJSONString(param));
            request.setAttribute("cache", param);
        }
        System.out.println(param);
        if (Cools.isEmpty(param)) {
            return R.parse(BaseRes.PARAM);
@@ -422,7 +429,12 @@
     * return
     */
    @PostMapping("/station/all")
    public synchronized R stationAll(){
    public synchronized R stationAll(HttpServletRequest request) {
        if (request != null) {
            String cachePayload = JSON.toJSONString(Collections.singletonMap("op", "stationAll"));
            log.info("[stationAll] cache: {}", cachePayload);
            request.setAttribute("cache", cachePayload);
        }
        return openService.stationAll();
    }
@@ -431,7 +443,11 @@
     * return
     */
    @PostMapping("/comb/auth")
    public synchronized R comb(@RequestBody ArrayList<MesToCombParam> param){
    public synchronized R comb(@RequestBody ArrayList<MesToCombParam> param, HttpServletRequest request) {
        if (request != null) {
            log.info("[comb] cache: {}", param == null ? "null" : JSON.toJSONString(param));
            request.setAttribute("cache", param);
        }
        List<MesToCombParam> errorComb = Lists.newArrayList();
        List<MesToCombParam> validComb = Lists.newArrayList();
        for (MesToCombParam mesToCombParam : param) {
@@ -459,6 +475,7 @@
            validComb.add(mesToCombParam);
        }
        for (MesToCombParam mesToCombParam : validComb) {
            mesToCombParam.setBoxType1("ERP");
            openService.mesToComb(mesToCombParam);
        }
        // TODO:待测试
@@ -474,10 +491,12 @@
     */
    @PostMapping("/outOrder")
    public synchronized R outOrder (@RequestBody ArrayList<OutTaskParam> params){
    public synchronized R outOrder(@RequestBody ArrayList<OutTaskParam> params, HttpServletRequest request) {
        if (Cools.isEmpty(params)) {
            return R.error("请求参数不能为空");
        }
        log.info("[outOrder] cache: {}", JSON.toJSONString(params));
        request.setAttribute("cache", params);
        Set<String> orderIds = new LinkedHashSet<>();
        for (OutTaskParam outTaskParam : params) {
            if (Cools.isEmpty(outTaskParam) || Cools.isEmpty(outTaskParam.getOrderId())) {
@@ -485,6 +504,38 @@
            }
            orderIds.add(outTaskParam.getOrderId());
        }
        Map<String, List<OutTaskParam>> linesByOrder = new LinkedHashMap<>();
        for (OutTaskParam outTaskParam : params) {
            linesByOrder.computeIfAbsent(outTaskParam.getOrderId(), k -> new ArrayList<>()).add(outTaskParam);
        }
        for (Map.Entry<String, List<OutTaskParam>> entry : linesByOrder.entrySet()) {
            String oid = entry.getKey();
            List<OutTaskParam> lines = entry.getValue();
            List<Integer> seqs = new ArrayList<>(lines.size());
            for (OutTaskParam line : lines) {
                if (line.getSeq() == null) {
                    return R.error("出库单「" + oid + "」序号不能为空");
                }
                seqs.add(line.getSeq());
            }
            Collections.sort(seqs);
            for (int i = 0; i < seqs.size(); i++) {
                if (!String.valueOf(seqs.get(i)).equals(String.valueOf(i + 1))) {
                    return R.error("出库单「" + oid + "」序号不连贯");
                }
            }
        }
        Set<String> seenPallet = new LinkedHashSet<>();
        for (OutTaskParam outTaskParam : params) {
            String pid = outTaskParam.getPalletId();
            String palletKey = pid == null ? "" : pid;
            if (!seenPallet.add(palletKey)) {
                return R.error("托盘号重复:" + (Cools.isEmpty(pid) ? "(空)" : pid));
            }
        }
//        if (!orderIds.isEmpty()) {
//            Set<String> existedOrderIds = new LinkedHashSet<>();
//            List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().in("user_no", orderIds));
@@ -504,37 +555,48 @@
//            }
//        }
        List<OutTaskParam> errorOutOrders = Lists.newArrayList();
        List<OutTaskParam> validOutOrders = Lists.newArrayList();
        List<OutTaskParam> missingStock = Lists.newArrayList();
        List<OutTaskParam> missingLoc = Lists.newArrayList();
        for (OutTaskParam outTaskParam : params) {
            // TODO:待測試,校驗庫存信息,不存在則返回
            int countLoc = locDetlService.selectCount(new EntityWrapper<LocDetl>().eq("zpallet", outTaskParam.getPalletId()));
            if (countLoc == 0){
                errorOutOrders.add(outTaskParam);
            if (countLoc == 0) {
                missingStock.add(outTaskParam);
                continue;
            }
            validOutOrders.add(outTaskParam);
        }
        for (OutTaskParam outTaskParam : validOutOrders) {
            R r = openService.outOrder(outTaskParam);
            if (!r.get("code").equals(200)){
                return r;
            LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_sts", "F").eq("barcode", outTaskParam.getPalletId()));
            if (locMast == null) {
                missingLoc.add(outTaskParam);
            }
        }
        if(errorOutOrders.size() > 0) {
            return R.error("库存中不存在该托盘").add(errorOutOrders);
        if (!missingStock.isEmpty()) {
            List<String> missingPalletIds = new ArrayList<>(missingStock.size());
            for (OutTaskParam p : missingStock) {
                String pid = p.getPalletId();
                missingPalletIds.add(Cools.isEmpty(pid) ? "(空)" : pid);
            }
            return R.error("库存中不存在该托盘:" + String.join(",", missingPalletIds)).add(missingStock);
        }
        if (!missingLoc.isEmpty()) {
            List<String> badPalletIds = new ArrayList<>(missingLoc.size());
            for (OutTaskParam p : missingLoc) {
                String pid = p.getPalletId();
                badPalletIds.add(Cools.isEmpty(pid) ? "(空)" : pid);
            }
            return R.error("没有找到托盘码对应库位:" + String.join(",", badPalletIds)).add(missingLoc);
        }
        return R.ok();
        return openService.outOrderBatch(params);
    }
    /**
     * pause out order
     */
    @PostMapping("/order/pakout/pause/default/v1")
    public synchronized R pakoutOrderPause(@RequestBody OpenOrderPakoutPauseParam param){
    public synchronized R pakoutOrderPause(@RequestBody OpenOrderPakoutPauseParam param, HttpServletRequest request) {
        if (request != null) {
            log.info("[pakoutOrderPause] cache: {}", param == null ? "null" : JSON.toJSONString(param));
            request.setAttribute("cache", param);
        }
        if (Cools.isEmpty(param) || Cools.isEmpty(param.getOrderId())) {
            return R.error("orderNo is empty");
        }
@@ -656,7 +718,11 @@
     * 任务查询接口
     */
    @PostMapping("/queryTask")
    public synchronized R queryTask(@RequestBody QueryTaskParam param) {
    public synchronized R queryTask(@RequestBody QueryTaskParam param, HttpServletRequest request) {
        if (request != null) {
            log.info("[queryTask] cache: {}", param == null ? "null" : JSON.toJSONString(param));
            request.setAttribute("cache", param);
        }
        if (Cools.isEmpty(param)) {
            return R.parse(BaseRes.PARAM);
        }