自动化立体仓库 - WMS系统
zwl
7 天以前 872dd98f359f6d6ff45dac82fe925a5abf4faa83
src/main/java/com/zy/asrs/controller/OpenController.java
@@ -125,6 +125,23 @@
        return R.ok().add(openService.pakinOrderComplete(param));
    }
    /**
     * 托盘入库历史记录重报ERP
     */
    @PostMapping("/order/pakin/erp/report/v1")
//    @AppAuth(memo = "入库历史重报ERP")
    public synchronized R reportPakinHistoryToErp(@RequestBody(required = false) List<String> barcodes) {
//        auth(appkey, barcodes, request);
        if (Cools.isEmpty(barcodes)) {
            return R.parse(BaseRes.PARAM);
        }
        try {
            return openService.reportPakinHistoryToErp(barcodes);
        } catch (Exception e) {
            return R.error(e.getMessage());
        }
    }
@@ -212,8 +229,8 @@
    @PostMapping("/arm/task/v1")
    @AppAuth(memo = "分拣线上报接收")
    public synchronized R TaskArmReport(@RequestHeader(required = false) String appkey,
                                           @RequestBody TaskArmReportParam param,
                                           HttpServletRequest request) {
                                        @RequestBody TaskArmReportParam param,
                                        HttpServletRequest request) {
        auth(appkey, param, request);
        if (Cools.isEmpty(param)) {
            return R.parse(BaseRes.PARAM);
@@ -257,8 +274,8 @@
    @PostMapping("/arm/task/cycle_result")
    @AppAuth(memo = "单码完成")
    public synchronized R TaskArmCycleResult(@RequestHeader(required = false) String appkey,
                                        @RequestBody TaskArmCycleResultParam param,
                                        HttpServletRequest request) {
                                             @RequestBody TaskArmCycleResultParam param,
                                             HttpServletRequest request) {
        auth(appkey, param, request);
        if (Cools.isEmpty(param)) {
            return R.parse(BaseRes.PARAM);
@@ -289,8 +306,8 @@
    @PostMapping("/arm/task/workspace_status")
    @AppAuth(memo = "托盘完成")
    public synchronized R TaskArmWorkspaceStatus(@RequestHeader(required = false) String appkey,
                                             @RequestBody TaskArmWorkspaceStatusParam param,
                                             HttpServletRequest request) {
                                                 @RequestBody TaskArmWorkspaceStatusParam param,
                                                 HttpServletRequest request) {
        auth(appkey, param, request);
        if (Cools.isEmpty(param)) {
            return R.parse(BaseRes.PARAM);
@@ -322,8 +339,8 @@
    @PostMapping("/arm/task/loc_status")
//    @AppAuth(memo = "托盘就绪状态查询")
    public synchronized R TaskArmLocStatus(@RequestHeader(required = false) String appkey,
                                                 @RequestBody ArmOKParam param,
                                                 HttpServletRequest request) {
                                           @RequestBody ArmOKParam param,
                                           HttpServletRequest request) {
        auth(appkey, param, request);
        if (Cools.isEmpty(param)) {
            return R.parse(BaseRes.PARAM);
@@ -349,8 +366,8 @@
    @PostMapping("/armAbnormalOperation")
//    @AppAuth(memo = "异常上报")
    public synchronized R ArmAbnormalOperation(@RequestHeader(required = false) String appkey,
                                                 @RequestBody TaskArmErrorParam param,
                                                 HttpServletRequest request) {
                                               @RequestBody TaskArmErrorParam param,
                                               HttpServletRequest request) {
        auth(appkey, param, request);
        if (Cools.isEmpty(param.getArm_no())) {
            return R.error("机械臂编号[Arm_no]不能为空");
@@ -447,6 +464,26 @@
            log.info("[comb] cache: {}", param == null ? "null" : JSON.toJSONString(param));
            request.setAttribute("cache", param);
        }
        if (Cools.isEmpty(param)) {
            return R.error("没有入库数据");
        }
        boolean boo =false;
        for (MesToCombParam mesToCombParam : param) {
            if (mesToCombParam.getOperateType()==2){
                int countLoc = locDetlService.selectCount(new EntityWrapper<LocDetl>().eq("zpallet", mesToCombParam.getPalletId()));
                int countWrk = wrkDetlService.selectCount(new EntityWrapper<WrkDetl>().eq("zpallet", mesToCombParam.getPalletId()));
                int countwait = waitPakinService.selectCount(new EntityWrapper<WaitPakin>().eq("zpallet",mesToCombParam.getPalletId()).eq("io_status", "Y"));
                if (countLoc > 0 || countWrk > 0 || countwait > 0) {
                    return R.error(mesToCombParam.getPalletId()+"-工作档/库存条码数据已存在,无法删除");
                }
                waitPakinService.delete(new EntityWrapper<WaitPakin>().eq("zpallet",mesToCombParam.getPalletId()));
                boo = true;
            }
        }
        if (boo){
            return R.ok();
        }
        List<MesToCombParam> errorComb = Lists.newArrayList();
        List<MesToCombParam> validComb = Lists.newArrayList();
        for (MesToCombParam mesToCombParam : param) {
@@ -495,7 +532,7 @@
        }
        log.info("[outOrder] cache: {}", JSON.toJSONString(params));
        request.setAttribute("cache", params);
        Map<String, List<OutTaskParam>> linesByBatch = new LinkedHashMap<>();
        Map<String, List<OutTaskParam>> linesByBatchSeq = new LinkedHashMap<>();
        for (OutTaskParam outTaskParam : params) {
            if (Cools.isEmpty(outTaskParam) || Cools.isEmpty(outTaskParam.getOrderId())) {
                return R.error("出库单号不能为空");
@@ -506,10 +543,10 @@
            if (Cools.isEmpty(outTaskParam.getStationId())) {
                return R.error("托盘「" + outTaskParam.getPalletId() + "」出库口编码不能为空");
            }
            linesByBatch.computeIfAbsent(outTaskParam.getBatchSeq(), k -> new ArrayList<>()).add(outTaskParam);
            linesByBatchSeq.computeIfAbsent(outTaskParam.getBatchSeq(), k -> new ArrayList<>()).add(outTaskParam);
        }
        for (Map.Entry<String, List<OutTaskParam>> entry : linesByBatch.entrySet()) {
        for (Map.Entry<String, List<OutTaskParam>> entry : linesByBatchSeq.entrySet()) {
            List<OutTaskParam> lines = entry.getValue();
            OutTaskParam head = lines.get(0);
            String oid = head.getOrderId();
@@ -544,8 +581,13 @@
            }
        }
        List<OutTaskParam> groupedParams = new ArrayList<>(params.size());
        for (List<OutTaskParam> lines : linesByBatchSeq.values()) {
            groupedParams.addAll(lines);
        }
        Set<String> seenPallet = new LinkedHashSet<>();
        for (OutTaskParam outTaskParam : params) {
        for (OutTaskParam outTaskParam : groupedParams) {
            String pid = outTaskParam.getPalletId();
            String palletKey = pid == null ? "" : pid;
            if (!seenPallet.add(palletKey)) {
@@ -574,7 +616,7 @@
        List<OutTaskParam> missingStock = Lists.newArrayList();
        List<OutTaskParam> missingLoc = Lists.newArrayList();
        for (OutTaskParam outTaskParam : params) {
        for (OutTaskParam outTaskParam : groupedParams) {
            int countLoc = locDetlService.selectCount(new EntityWrapper<LocDetl>().eq("zpallet", outTaskParam.getPalletId()));
            if (countLoc == 0) {
                missingStock.add(outTaskParam);
@@ -602,7 +644,7 @@
            return R.error("没有找到托盘码对应库位:" + String.join(",", badPalletIds)).add(missingLoc);
        }
        return openService.outOrderBatch(params);
        return openService.outOrderBatch(linesByBatchSeq);
    }
    /**
@@ -654,11 +696,20 @@
        return param.getOrderId() + "#" + param.getBatchSeq();
    }
    /**
     * 推荐出库站点
     */
    @PostMapping("/pakoutStaNo")
    public synchronized R pakoutStaNo(@RequestBody List<String> barcodes) {
        String StaNo = "1,2,3,4,5";
        return R.ok().add(StaNo);
    }
    /*************************************电视机程序***********************************************/
    @GetMapping("/locDetl/statistics")
    public R locDetlStatistics(){
    public synchronized R locDetlStatistics(){
        HashMap<String, Object> param = new HashMap<>();
        Page<LocDetl> stockStatis = locDetlService.getStockStatis(toPage(1, 100, param, LocDetl.class));
        for (LocDetl locDetl : stockStatis.getRecords()) {
@@ -671,15 +722,15 @@
    }
    @GetMapping("/line/charts")
    public R locIoLineCharts(){
    public synchronized R locIoLineCharts(){
        Map<String,Object> map=new HashMap<String, Object>();
        List<AxisBean> list = new ArrayList<AxisBean>();
        List<WorkChartAxis> listChart = reportQueryMapper.getChartAxis();
        if(listChart!=null) {
            ArrayList<Integer> data1 = new ArrayList<Integer>();
            ArrayList<Integer> data2 = new ArrayList<Integer>();
            ArrayList<Number> data1 = new ArrayList<Number>();
            ArrayList<Number> data2 = new ArrayList<Number>();
            SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
            Calendar calendar = Calendar.getInstance();
@@ -702,25 +753,61 @@
                }
            }
            AxisBean inqty = new AxisBean();
            inqty.setName("入库数量");
            Integer[] array1 = new Integer[data1.size()];
            inqty.setName("入库托盘数");
            Number[] array1 = new Number[data1.size()];
            inqty.setData(data1.toArray(array1));
            list.add(inqty);
            AxisBean outqty = new AxisBean();
            outqty.setName("出库数量");
            Integer[] array2 = new Integer[data2.size()];
            outqty.setName("出库托盘数");
            Number[] array2 = new Number[data2.size()];
            outqty.setData(data2.toArray(array2));
            list.add(outqty);
            AxisBean  teu= new AxisBean();
            teu.setName("TEU");
            List<WorkTeuTotalAxis> workTeuTotalAxes = reportQueryMapper.getteuTotal();
            ArrayList<Number> data3 = new ArrayList<Number>();
            for (WorkTeuTotalAxis w : workTeuTotalAxes) {
                data3.add(w.getTeu_total());
            }
            Number[] array3 = new Number[data3.size()];
            teu.setData(data3.toArray(array3));
            list.add(teu);
            AxisBean cube5 = new AxisBean();
            cube5.setName("入库体积");
            List<WorkCubeTotalAxis> workCubeTotalAxes = reportQueryMapper.getInboundCubeTotal();
            Map<String, WorkCubeTotalAxis> cubeMap = new HashMap<String, WorkCubeTotalAxis>();
            if (workCubeTotalAxes != null) {
                for (WorkCubeTotalAxis w : workCubeTotalAxes) {
                    if (w.getYmd() != null) {
                        cubeMap.put(w.getYmd(), w);
                    }
                }
            }
            ArrayList<Number> data4 = new ArrayList<Number>();
            SimpleDateFormat sfCube = new SimpleDateFormat("yyyy-MM-dd");
            Calendar calendarCube = Calendar.getInstance();
            calendarCube.add(Calendar.DATE, -12);
            for (int i = 0; i < 12; i++) {
                calendarCube.add(Calendar.DATE, 1);
                String str = sfCube.format(calendarCube.getTime());
                WorkCubeTotalAxis cubeAxis = cubeMap.get(str);
                data4.add(cubeAxis == null || cubeAxis.getCube5Total() == null ? 0 : cubeAxis.getCube5Total());
            }
            Number[] array4 = new Number[data4.size()];
            cube5.setData(data4.toArray(array4));
            list.add(cube5);
        }
        map.put("rows",list);
        return R.ok(map);
    }
    /**
     * 近24小时入出库折线(横轴小时),与按日 {@link #locIoLineCharts()} 数据口径不同,供电视机「作业效率」使用
     * 入出库按小时折线:横轴为「当前整点起向前共 12 小时」滚动窗口,与库表 ymd(yyyy-MM-dd HH)对齐
     */
    @GetMapping("/line/charts/hourly")
    public R locIoLineChartsHourly() {
    public synchronized R locIoLineChartsHourly() {
        Map<String, Object> map = new HashMap<>();
        List<AxisBean> list = new ArrayList<>();
@@ -731,45 +818,82 @@
        ArrayList<Integer> data1 = new ArrayList<>();
        ArrayList<Integer> data2 = new ArrayList<>();
        ArrayList<Double> data3 = new ArrayList<>();
        ArrayList<Double> data4 = new ArrayList<>();
        ArrayList<Double> data5 = new ArrayList<>();
        List<String> categories = new ArrayList<>();
        final int n = 12;
        SimpleDateFormat sfKey = new SimpleDateFormat("yyyy-MM-dd HH");
        SimpleDateFormat sfLabel = new SimpleDateFormat("HH:00");
        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.MINUTE, 0);
        calendar.set(Calendar.SECOND, 0);
        calendar.set(Calendar.MILLISECOND, 0);
        calendar.add(Calendar.HOUR_OF_DAY, -23);
        calendar.add(Calendar.HOUR_OF_DAY, -(n - 1));
        for (int i = 0; i < 24; i++) {
        for (int i = 0; i < n; i++) {
            String key = sfKey.format(calendar.getTime());
            categories.add(sfLabel.format(calendar.getTime()));
            categories.add(String.valueOf(calendar.get(Calendar.HOUR_OF_DAY)));
            int inV = 0;
            int outV = 0;
            double inC = 0;
            double outC = 0;
            double outD = 0;
            for (WorkChartAxis w : listChart) {
                if (w.getYmd() != null && key.equals(w.getYmd().trim())) {
                    inV = w.getInqty();
                    outV = w.getOutqty();
                    inC = w.getCubeInqty();
                    outC = w.getCubeOutqty();
                    outD = w.getOutTeu();
                    break;
                }
            }
            data1.add(inV);
            data2.add(outV);
            data3.add(inC);
            data4.add(outC);
            data5.add(outD);
            calendar.add(Calendar.HOUR_OF_DAY, 1);
        }
        AxisBean inqty = new AxisBean();
        inqty.setName("入库数量");
        inqty.setName("入库托盘数");
        Integer[] array1 = new Integer[data1.size()];
        inqty.setData(data1.toArray(array1));
        list.add(inqty);
        AxisBean outqty = new AxisBean();
        outqty.setName("出库数量");
        outqty.setName("出库托盘数");
        Integer[] array2 = new Integer[data2.size()];
        outqty.setData(data2.toArray(array2));
        list.add(outqty);
        if (data3.size() >0) {
            AxisBean cubeInqty = new AxisBean();
            cubeInqty.setName("入库体积");
            Double [] array3 = new Double[data3.size()];
            cubeInqty.setData(data3.toArray(array3));
            list.add(cubeInqty);
        }
        if (data4.size() >0) {
            AxisBean cubeOutqty = new AxisBean();
            cubeOutqty.setName("出库体积");
            Double[] array4 = new Double[data4.size()];
            cubeOutqty.setData(data4.toArray(array4));
            list.add(cubeOutqty);
        }
        if (data5.size() >0) {
            AxisBean cubeOutqty = new AxisBean();
            cubeOutqty.setName("出库TEU");
            Double[] array5 = new Double[data4.size()];
            cubeOutqty.setData(data5.toArray(array5));
            list.add(cubeOutqty);
        }
        map.put("categories", categories);
        map.put("rows", list);
@@ -807,7 +931,8 @@
        }
        // 总库位数
        Integer total = (int) Arith.add(0, locUseRate.getFqty(), locUseRate.getOqty(), locUseRate.getUqty(), locUseRate.getXqty());
        Integer total1 = (int) Arith.add(0, locUseRate.getFqty(), locUseRate.getOqty(), locUseRate.getUqty(), locUseRate.getXqty());
        Integer total = total1>40000?6528:total1;
        // 使用中
        Integer used = locUseRate.getFqty() + locUseRate.getUqty();
        // 库位使用率
@@ -851,7 +976,64 @@
        map.put("taskNo", param.getTaskNo());
        map.put("ioType", wrkMast.getIoType());
        map.put("wrkDetls", wrkDetls);
        Integer count = 0;
        String supp = "";
        //该订单累计入出库件数
        Integer ioType = wrkMast.getIoType();
        if (ioType != null && ioType < 100) {
            Date endTime = new Date();
            Date startTime = resolveBusinessDayStart(endTime);
            Long inboundCount = wrkMastLogService.countInboundHistoryBySourceStaNo(startTime, endTime, resolveInboundStationNo(wrkMast));
            supp = String.valueOf(inboundCount);
        }else {
            List<WrkMast> orderNo = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("user_no", wrkMast.getUserNo()));
            List<WrkMastLog> userNo = wrkMastLogService.selectList(new EntityWrapper<WrkMastLog>().eq("user_no", wrkMast.getUserNo()).eq("wrk_sts",15L));
            if (userNo != null && userNo.size() > 0) {
                count = userNo.size()+1;
            }
            if (orderNo != null && orderNo.size() > 0) {
                count=orderNo.size()+count;
            }
            supp = count + "";
        }
        map.put("supp", supp);
        //耗时
        Long costTime = resolveCostTime(wrkMast);
        map.put("costTime", String.valueOf(costTime));
        return R.ok().add(map);
    }
    private Long resolveCostTime(WrkMast wrkMast) {
        if (wrkMast == null || wrkMast.getIoType() == null) {
            return 0L;
        }
        Date endTime = new Date();
        Date startTime = resolveBusinessDayStart(endTime);
        Integer wrkSts = wrkMast.getIoType() < 100 ? 5 : 15;
        return wrkMastLogService.sumCostTimeByWrkSts(startTime, endTime, wrkSts);
    }
    private Integer resolveInboundStationNo(WrkMast wrkMast) {
        if (wrkMast == null) {
            return null;
        }
        return wrkMast.getSourceStaNo() == null ? wrkMast.getStaNo() : wrkMast.getSourceStaNo();
    }
    private Date resolveBusinessDayStart(Date now) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(now);
        calendar.set(Calendar.HOUR_OF_DAY, 8);
        calendar.set(Calendar.MINUTE, 0);
        calendar.set(Calendar.SECOND, 0);
        calendar.set(Calendar.MILLISECOND, 0);
        if (now.before(calendar.getTime())) {
            calendar.add(Calendar.DATE, -1);
        }
        return calendar.getTime();
    }
}