| | |
| | | // 卷包产量统计 |
| | | Double rollerOutput = 0.0; |
| | | Double packerOutput = 0.0; |
| | | // 明细列表 |
| | | // 明细列表(仅存最终正数结果) |
| | | List<StoreSilkDetailVo> rollerDetailList = new ArrayList<>(); |
| | | List<StoreSilkDetailVo> packerDetailList = new ArrayList<>(); |
| | | // 操作记录列表(存所有增减过程) |
| | | List<StoreSilkDetailVo> rollerRecordList = new ArrayList<>(); |
| | | List<StoreSilkDetailVo> packerRecordList = new ArrayList<>(); |
| | | |
| | | for (int s = 0; s < distShiftList.size(); s++) { |
| | | MdShiftBo shiftBo = distShiftList.get(s); |
| | |
| | | // 先把统计结束时刻累计值加进来:current = Qty(calcEnd) |
| | | currentRollerOutput += rData.getQty(); |
| | | |
| | | // 记录过程:班次截止累计 |
| | | StoreSilkDetailVo endRecord = new StoreSilkDetailVo(); |
| | | endRecord.setFsNum(fsNum.substring(2, 3)); |
| | | endRecord.setSiloNum(containerNum); |
| | | endRecord.setPipeNum(channel); |
| | | endRecord.setEquNo(equNo); |
| | | endRecord.setShiftCode(shift); |
| | | endRecord.setShiftStartTime(calcStartDate); |
| | | endRecord.setShiftEndTime(calcEndDate); |
| | | endRecord.setOutput(rData.getQty()); |
| | | endRecord.setCalcType("班次截止累计"); |
| | | endRecord.setHitTime(rData.getTime()); |
| | | rollerRecordList.add(endRecord); |
| | | |
| | | // 2) 扣“头”:如果统计开始时刻晚于班次开始,则减去 Qty(calcStart) |
| | | if (calcStartDate.after(stimDate)) { |
| | | LocalDateTime calcStartLdt = LocalDateTime.ofInstant(calcStartDate.toInstant(), zone); |
| | |
| | | RollerTimeData rBeginData = rollerTimeDataMapper.selectOne(beginRlqw); |
| | | if (rBeginData != null) { |
| | | currentRollerOutput -= rBeginData.getQty(); |
| | | |
| | | // 记录过程:扣除头部产量 |
| | | StoreSilkDetailVo beginRecord = new StoreSilkDetailVo(); |
| | | beginRecord.setFsNum(fsNum.substring(2, 3)); |
| | | beginRecord.setSiloNum(containerNum); |
| | | beginRecord.setPipeNum(channel); |
| | | beginRecord.setEquNo(equNo); |
| | | beginRecord.setShiftCode(shift); |
| | | beginRecord.setShiftStartTime(calcStartDate); |
| | | beginRecord.setShiftEndTime(calcEndDate); |
| | | beginRecord.setOutput(-rBeginData.getQty()); // 负数表示扣除 |
| | | beginRecord.setCalcType("扣除出料前累计"); |
| | | beginRecord.setHitTime(rBeginData.getTime()); |
| | | rollerRecordList.add(beginRecord); |
| | | } |
| | | } |
| | | } |
| | |
| | | // 先把统计结束时刻累计值加进来:current = Qty(calcEnd) |
| | | currentPackerOutput += pData.getTsQty(); |
| | | |
| | | // 记录过程:班次截止累计 |
| | | StoreSilkDetailVo endRecord = new StoreSilkDetailVo(); |
| | | endRecord.setFsNum(fsNum.substring(2, 3)); |
| | | endRecord.setSiloNum(containerNum); |
| | | endRecord.setPipeNum(channel); |
| | | endRecord.setEquNo(equNo); |
| | | endRecord.setShiftCode(shift); |
| | | endRecord.setShiftStartTime(calcStartDate); |
| | | endRecord.setShiftEndTime(calcEndDate); |
| | | endRecord.setOutput(pData.getTsQty()); |
| | | endRecord.setCalcType("班次截止累计"); |
| | | endRecord.setHitTime(pData.getTime()); |
| | | packerRecordList.add(endRecord); |
| | | |
| | | // 2) 扣“头”:如果统计开始时刻晚于班次开始,则减去 Qty(calcStart) |
| | | if (calcStartDate.after(stimDate)) { |
| | | LocalDateTime calcStartLdt = LocalDateTime.ofInstant(calcStartDate.toInstant(), zone); |
| | |
| | | PackerTimeData pBeginData = packerTimeDataMapper.selectOne(beginPlqw); |
| | | if (pBeginData != null) { |
| | | currentPackerOutput -= pBeginData.getTsQty(); |
| | | |
| | | // 记录过程:扣除头部产量 |
| | | StoreSilkDetailVo beginRecord = new StoreSilkDetailVo(); |
| | | beginRecord.setFsNum(fsNum.substring(2, 3)); |
| | | beginRecord.setSiloNum(containerNum); |
| | | beginRecord.setPipeNum(channel); |
| | | beginRecord.setEquNo(equNo); |
| | | beginRecord.setShiftCode(shift); |
| | | beginRecord.setShiftStartTime(calcStartDate); |
| | | beginRecord.setShiftEndTime(calcEndDate); |
| | | beginRecord.setOutput(-pBeginData.getTsQty()); // 负数表示扣除 |
| | | beginRecord.setCalcType("扣除出料前累计"); |
| | | beginRecord.setHitTime(pBeginData.getTime()); |
| | | packerRecordList.add(beginRecord); |
| | | } |
| | | } |
| | | } |
| | |
| | | storeSilkInfoVo.setPackerOutput(packerOutput); |
| | | storeSilkInfoVo.setRollerDetailList(rollerDetailList); |
| | | storeSilkInfoVo.setPackerDetailList(packerDetailList); |
| | | storeSilkInfoVo.setRollerRecordList(rollerRecordList); |
| | | storeSilkInfoVo.setPackerRecordList(packerRecordList); |
| | | |
| | | } |
| | | |
| | |
| | | LambdaQueryWrapper<StoreSilkInfo> lqw = Wrappers.lambdaQuery(); |
| | | lqw.orderByAsc(StoreSilkInfo::getId); |
| | | lqw.like(StringUtils.isNotBlank(bo.getMaterialname()), StoreSilkInfo::getMaterialname, bo.getMaterialname()); |
| | | lqw.eq(StringUtils.isNotBlank(bo.getBatchcode()), StoreSilkInfo::getBatchcode, bo.getBatchcode()); |
| | | lqw.eq(bo.getActualstarttime() != null, StoreSilkInfo::getActualstarttime, bo.getActualstarttime()); |
| | | lqw.like(StringUtils.isNotBlank(bo.getBatchcode()), StoreSilkInfo::getBatchcode, bo.getBatchcode()); |
| | | if (bo.getActualstarttime() != null) { |
| | | ZoneId zone = ZoneId.systemDefault(); |
| | | LocalDate day = bo.getActualstarttime().toInstant().atZone(zone).toLocalDate(); |
| | | Date dayStart = Date.from(day.atStartOfDay(zone).toInstant()); |
| | | Date nextDayStart = Date.from(day.plusDays(1).atStartOfDay(zone).toInstant()); |
| | | lqw.ge(StoreSilkInfo::getActualstarttime, dayStart); |
| | | lqw.lt(StoreSilkInfo::getActualstarttime, nextDayStart); |
| | | } |
| | | lqw.eq(bo.getDistimebegin() != null, StoreSilkInfo::getDistimebegin, bo.getDistimebegin()); |
| | | lqw.eq(bo.getDistimeend() != null, StoreSilkInfo::getDistimeend, bo.getDistimeend()); |
| | | lqw.eq(StringUtils.isNotBlank(bo.getSiloid()), StoreSilkInfo::getSiloid, bo.getSiloid()); |
| | | if (StringUtils.isNotBlank(bo.getSiloid())) { |
| | | // 支持多个柜号查询,以逗号分隔 |
| | | String[] siloids = bo.getSiloid().split(","); |
| | | lqw.and(wrapper -> { |
| | | for (String val : siloids) { |
| | | val = val.trim(); |
| | | if (StringUtils.isBlank(val)) { |
| | | continue; |
| | | } |
| | | String finalVal = val; |
| | | // 使用 OR 连接多个柜号条件 |
| | | wrapper.or(w -> { |
| | | try { |
| | | int num = Integer.parseInt(finalVal); |
| | | String padded = String.format("%02d", num); |
| | | // 匹配 _1 或 _01 (兼容不补零和补零的情况) |
| | | w.likeLeft(StoreSilkInfo::getSiloid, "_" + num) |
| | | .or() |
| | | .likeLeft(StoreSilkInfo::getSiloid, "_" + padded); |
| | | } catch (NumberFormatException e) { |
| | | // 非数字则按原值匹配 |
| | | w.eq(StoreSilkInfo::getSiloid, finalVal); |
| | | } |
| | | }); |
| | | } |
| | | }); |
| | | } |
| | | lqw.between(params.get("beginTime") != null && params.get("endTime") != null, |
| | | StoreSilkInfo::getDistimeend, params.get("beginTime"), params.get("endTime")); |
| | | return lqw; |