|  |  | @ -8,6 +8,7 @@ import cn.hutool.core.util.StrUtil; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |  |  |  | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |  |  |  | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |  |  |  | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |  |  |  | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.github.pagehelper.PageHelper; |  |  |  | import com.github.pagehelper.PageHelper; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.common.res.BaseResponse; |  |  |  | import com.glxp.api.common.res.BaseResponse; | 
			
		
	
	
		
		
			
				
					|  |  | @ -15,6 +16,7 @@ import com.glxp.api.common.util.ResultVOUtils; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.constant.Constant; |  |  |  | import com.glxp.api.constant.Constant; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.constant.ConstantStatus; |  |  |  | import com.glxp.api.constant.ConstantStatus; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.dao.auth.InvWarehouseDao; |  |  |  | import com.glxp.api.dao.auth.InvWarehouseDao; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import com.glxp.api.dao.basic.BasicProductsDao; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.dao.basic.SysWorkplaceBusMapper; |  |  |  | import com.glxp.api.dao.basic.SysWorkplaceBusMapper; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.dao.collect.IoCollectCodeBackMapper; |  |  |  | import com.glxp.api.dao.collect.IoCollectCodeBackMapper; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.dao.collect.IoCollectCodeMapper; |  |  |  | import com.glxp.api.dao.collect.IoCollectCodeMapper; | 
			
		
	
	
		
		
			
				
					|  |  | @ -23,10 +25,7 @@ import com.glxp.api.dao.inout.IoCodeTempDao; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.entity.auth.AuthAdmin; |  |  |  | import com.glxp.api.entity.auth.AuthAdmin; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.entity.auth.InvWarehouseEntity; |  |  |  | import com.glxp.api.entity.auth.InvWarehouseEntity; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.entity.auth.SysWorkplace; |  |  |  | import com.glxp.api.entity.auth.SysWorkplace; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.entity.basic.BasicBussinessTypeEntity; |  |  |  | import com.glxp.api.entity.basic.*; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.entity.basic.CompanyProductRelevanceEntity; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.entity.basic.SysWorkplaceBus; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.entity.basic.SysWorkplaceDocumentEntity; |  |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.entity.collect.*; |  |  |  | import com.glxp.api.entity.collect.*; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.entity.inout.IoCodeTempEntity; |  |  |  | import com.glxp.api.entity.inout.IoCodeTempEntity; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.entity.inout.IoOrderEntity; |  |  |  | import com.glxp.api.entity.inout.IoOrderEntity; | 
			
		
	
	
		
		
			
				
					|  |  | @ -61,6 +60,8 @@ import org.springframework.transaction.annotation.Transactional; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | import javax.annotation.Resource; |  |  |  | import javax.annotation.Resource; | 
			
		
	
		
		
			
				
					
					|  |  |  | import java.math.BigDecimal; |  |  |  | import java.math.BigDecimal; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import java.math.RoundingMode; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import java.text.DecimalFormat; | 
			
		
	
		
		
			
				
					
					|  |  |  | import java.util.*; |  |  |  | import java.util.*; | 
			
		
	
		
		
			
				
					
					|  |  |  | import java.util.stream.Collectors; |  |  |  | import java.util.stream.Collectors; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | @ -785,4 +786,130 @@ public class IoCollectOrderBackupService extends ServiceImpl<IoCollectOrderBacku | 
			
		
	
		
		
			
				
					
					|  |  |  |         collectOrderUploadCountResponse.setFifoSplitTwoCount(fifoSplitTwoCount); |  |  |  |         collectOrderUploadCountResponse.setFifoSplitTwoCount(fifoSplitTwoCount); | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     @Resource | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     private BasicProductsDao basicProductsDao; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     public Page<IoCollectOrderResponse> filterorderStatsList(CollectOrderRequest collectOrderRequest) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         List<IoCollectOrderResponse> data = ioCollectOrderBackupMapper.filterorderStatsList(collectOrderRequest); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //        for (IoCollectOrderResponse ioCollectOrderResponse : data){
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //            Integer newScanCount = 0;
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //            Integer shouldCount = 0;
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //            List<IoCollectOrderBizBackup> orderBizBackups = ioCollectOrderBizBackupService.listByBillNo(ioCollectOrderResponse.getBillNo());
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //            // 遍历集合进行累加
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //            for (IoCollectOrderBizBackup collectOrderBizResponse : orderBizBackups) {
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //                newScanCount += (collectOrderBizResponse.getScanCount() != null) ? collectOrderBizResponse.getScanCount() : 0;
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //                shouldCount += getCount(collectOrderBizResponse);
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //            }
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //            ioCollectOrderResponse.setScanCount(newScanCount);
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //            ioCollectOrderResponse.setShouldCount(shouldCount);
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //            ioCollectOrderResponse.setScanRate(getScanRate(shouldCount,newScanCount));
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //            if (newScanCount == shouldCount){
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //                ioCollectOrderResponse.setStorard(1);
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //            }else {
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //                ioCollectOrderResponse.setStorard(0);
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //            }
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //        }
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         // 筛选 setStorard 为 1 的数据
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         List<IoCollectOrderResponse> filteredData = new ArrayList<>(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         List<IoCollectOrderResponse> filteredData1 = new ArrayList<>(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         List<IoCollectOrderResponse> filteredData2 = new ArrayList<>(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         for (IoCollectOrderResponse ioCollectOrderResponse : data) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             Integer newScanCount = 0; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             Integer shouldCount = 0; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             List<IoCollectOrderBizBackup> orderBizBackups = ioCollectOrderBizBackupService.listByBillNo(ioCollectOrderResponse.getBillNo()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             // 遍历集合进行累加
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             for (IoCollectOrderBizBackup collectOrderBizResponse : orderBizBackups) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 newScanCount += (collectOrderBizResponse.getScanCount() != null) ? collectOrderBizResponse.getScanCount() : 0; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 shouldCount += getCount(collectOrderBizResponse); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             // 设置计算结果
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             ioCollectOrderResponse.setScanCount(newScanCount); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             ioCollectOrderResponse.setShouldCount(shouldCount); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             ioCollectOrderResponse.setScanRate(getScanRate(shouldCount, newScanCount)); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             ioCollectOrderResponse.setStorard(newScanCount.equals(shouldCount) ? 1 : 0); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             if (collectOrderRequest.getStorard() == null){ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     filteredData.add(ioCollectOrderResponse); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             }else if (collectOrderRequest.getStorard() == 1){ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 if (ioCollectOrderResponse.getStorard() == 1) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     filteredData.add(ioCollectOrderResponse); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             }else if (collectOrderRequest.getStorard() == 0){ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 if (ioCollectOrderResponse.getStorard() == 0) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     filteredData.add(ioCollectOrderResponse); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         // 获取分页参数
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         Integer pageNum = collectOrderRequest.getPage() != null ? collectOrderRequest.getPage() : 1; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         Integer pageSize = collectOrderRequest.getLimit() != null ? collectOrderRequest.getLimit() : 10; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         // 计算分页信息
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         int total = filteredData.size(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         int totalPages = (int) Math.ceil((double) total / pageSize); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         int start = (pageNum - 1) * pageSize; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         int end = Math.min(start + pageSize, total); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         // 截取分页数据
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         List<IoCollectOrderResponse> pageData = filteredData.subList(start, end); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         // 创建分页对象
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         Page<IoCollectOrderResponse> page = new Page<>(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         page.setCurrent(pageNum); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         page.setSize(pageSize); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         page.setTotal(total); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         page.setPages(totalPages); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         page.setRecords(pageData); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         return page; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     public Integer getCount(IoCollectOrderBizBackup collectOrderBizResponse){ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         Integer shouldCount = 0; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         List<BasicProductsEntity> productList = basicProductsDao.selectList( | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 new LambdaQueryWrapper<BasicProductsEntity>() | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         .eq(BasicProductsEntity::getYbbm, collectOrderBizResponse.getYbbm()) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         .eq(BasicProductsEntity::getPackLevel, "1")); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         BasicProductsEntity product = productList.get(0); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         Integer myBhxjsl = product.getBhxjsl(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         double quotient = (double) collectOrderBizResponse.getCount() / myBhxjsl; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         int integerPart = (int) quotient; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         if (quotient == integerPart) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             if (integerPart == 0) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 if (collectOrderBizResponse.getAutoTagStatus() != 2) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     shouldCount = 1; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             } else { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 shouldCount = integerPart; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } else { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             if (IntUtil.value(collectOrderBizResponse.getAutoTagStatus()) == 2) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 shouldCount = 0; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             } else { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 shouldCount = integerPart + 1; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         return shouldCount; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     public String getScanRate(Integer scanCount,Integer shouldCount) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         if (scanCount == null || scanCount == 0) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             return  0.00 + "%" ; // 或返回 null 根据业务需求
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         double v = BigDecimal.valueOf(shouldCount) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 .divide(BigDecimal.valueOf(scanCount), 4, RoundingMode.HALF_UP) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 .multiply(BigDecimal.valueOf(100)) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 .setScale(2, RoundingMode.HALF_UP) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 .doubleValue(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         DecimalFormat df = new DecimalFormat("#.00"); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         return df.format(v) + "%"; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
	
		
		
			
				
					|  |  | 
 |