自动化立体仓库 - WMS系统
zwl
2 天以前 c747884a92bdb6874d32d69a5c0da7533afeceee
2.修复数字孪生
1个文件已修改
50 ■■■■ 已修改文件
src/main/java/com/zy/asrs/service/impl/DigitalTwinServiceImpl.java 50 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/service/impl/DigitalTwinServiceImpl.java
@@ -252,33 +252,53 @@
        List<DtLocVo> locVos = new ArrayList<>();
        Date startTime;
        Date endTime;
        if (startDate == null || endDate == null || startDate.isEmpty() || endDate.isEmpty()){
            Date now = new Date();
            Calendar calendar = Calendar.getInstance();
            calendar.setTime(now);
            calendar.add(Calendar.DAY_OF_MONTH, -7);
            Date start = calendar.getTime();
            SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
            endDate = sdf.format(now);
            startDate = sdf.format(start);
        }
        List<LocCount> locCounts;
        if (areaId != null && !areaId.isEmpty()) {
            locCounts = locCountMapper.getByAreaAndDate(areaId, Integer.parseInt(startDate), Integer.parseInt(endDate));
            startTime = calendar.getTime();
            endTime = now;
        } else {
            locCounts = locCountMapper.getByDate(Integer.parseInt(startDate), Integer.parseInt(endDate));
            SimpleDateFormat sdf;
            try {
                if (startDate.length() == 8 && endDate.length() == 8) {
                    sdf = new SimpleDateFormat("yyyyMMdd");
                    startTime = sdf.parse(startDate);
                    endTime = sdf.parse(endDate);
                } else {
                    sdf = new SimpleDateFormat("yyyy-MM-dd");
                    startTime = sdf.parse(startDate);
                    endTime = sdf.parse(endDate);
                }
            } catch (ParseException e) {
                Date now = new Date();
                Calendar calendar = Calendar.getInstance();
                calendar.setTime(now);
                calendar.add(Calendar.DAY_OF_MONTH, -7);
                startTime = calendar.getTime();
                endTime = now;
            }
        }
        int totalLoc = locMastMapper.selectCount(new EntityWrapper<LocMast>().ne("loc_sts", "Z"));
        int usedLoc = locMastMapper.selectCount(new EntityWrapper<LocMast>().in("loc_sts", Arrays.asList("F", "P", "Q", "R", "S", "X")));
        int idleNum = totalLoc - usedLoc;
        for (LocCount locCount : locCounts) {
            String date = locCount.getDate().toString();
            String locDate = date.substring(0, 4) + "-" + date.substring(4, 6) + "-" + date.substring(6, 8);
        SimpleDateFormat outSdf = new SimpleDateFormat("yyyy-MM-dd");
        Calendar cursor = Calendar.getInstance();
        cursor.setTime(startTime);
        Calendar endCursor = Calendar.getInstance();
        endCursor.setTime(endTime);
        while (!cursor.after(endCursor)) {
            DtLocVo dtLocVo = DtLocVo.builder()
                    .locDate(locDate)
                    .idleNum(locCount.getRemainNum())
                    .locDate(outSdf.format(cursor.getTime()))
                    .idleNum(idleNum)
                    .build();
            locVos.add(dtLocVo);
            cursor.add(Calendar.DAY_OF_MONTH, 1);
        }
        return locVos;