|
|
|
@ -18,6 +18,7 @@ import org.springblade.common.utils.CommonUtil;
|
|
|
|
|
import org.springblade.core.redis.cache.BladeRedis; |
|
|
|
|
import org.springblade.core.secure.BladeUser; |
|
|
|
|
import org.springblade.core.secure.utils.AuthUtil; |
|
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
|
import org.springblade.core.tool.utils.Func; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
@ -284,6 +285,68 @@ public class WarehouseIndexServiceImpl implements IWarehouseIndexService {
|
|
|
|
|
return indexHandOrderDataVO; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Map<String, List<IndexAftersalesVO>> aftersalesData(List<Long> warehouseIds) { |
|
|
|
|
BladeUser user = AuthUtil.getUser(); |
|
|
|
|
List<IndexAftersalesVO> dayDataList = new ArrayList<>(); |
|
|
|
|
List<IndexAftersalesVO> monthDataList = new ArrayList<>(); |
|
|
|
|
Map<String, List<IndexAftersalesVO>> map = new HashMap<>(); |
|
|
|
|
if (!warehouseIds.isEmpty()) { |
|
|
|
|
for (Long warehouseId : warehouseIds) { |
|
|
|
|
String dayKey = CacheNames.tenantKey(user.getTenantId(), "warehouseId:" + warehouseId, ":aftersalesData:day"); |
|
|
|
|
String monthKey = CacheNames.tenantKey(user.getTenantId(), "warehouseId:" + warehouseId, ":aftersalesData:month"); |
|
|
|
|
IndexAftersalesVO dataDay = bladeRedis.get(dayKey); |
|
|
|
|
BasicdataWarehouseEntity entityWarehouseId = warehouseClient.getEntityWarehouseId(warehouseId); |
|
|
|
|
if (Objects.isNull(dataDay)) { |
|
|
|
|
|
|
|
|
|
dataDay = warehouseIndexMapper.findAftersalesDataByDay(warehouseId); |
|
|
|
|
if (Objects.isNull(dataDay)) { |
|
|
|
|
dataDay = new IndexAftersalesVO(); |
|
|
|
|
dataDay.setWarehouseName(entityWarehouseId.getName()); |
|
|
|
|
dataDay.setTotalNum(0); |
|
|
|
|
dataDay.setUnCompleteNum(0); |
|
|
|
|
dataDay.setCompleteNum(0); |
|
|
|
|
dataDay.setProcessingRate(0); |
|
|
|
|
} else { |
|
|
|
|
dataDay.setCompleteNum(dataDay.getTotalNum() - dataDay.getUnCompleteNum()); |
|
|
|
|
double a = (double) dataDay.getCompleteNum() / dataDay.getTotalNum() * 100; |
|
|
|
|
dataDay.setProcessingRate(a); |
|
|
|
|
} |
|
|
|
|
bladeRedis.setEx(dayKey, dataDay, 3600L); |
|
|
|
|
} |
|
|
|
|
dayDataList.add(dataDay); |
|
|
|
|
|
|
|
|
|
IndexAftersalesVO dataMonth = bladeRedis.get(monthKey); |
|
|
|
|
if (Objects.isNull(dataMonth)) { |
|
|
|
|
|
|
|
|
|
dataMonth = warehouseIndexMapper.findAftersalesDataByMonth(warehouseId); |
|
|
|
|
if (Objects.isNull(dataMonth)) { |
|
|
|
|
dataMonth = new IndexAftersalesVO(); |
|
|
|
|
dataMonth.setWarehouseName(entityWarehouseId.getName()); |
|
|
|
|
dataMonth.setTotalNum(0); |
|
|
|
|
dataMonth.setCompleteNum(0); |
|
|
|
|
dataMonth.setUnCompleteNum(0); |
|
|
|
|
dataMonth.setProcessingRate(0); |
|
|
|
|
} else { |
|
|
|
|
dataMonth.setCompleteNum(dataDay.getTotalNum() - dataDay.getUnCompleteNum()); |
|
|
|
|
double b = (double) dataMonth.getCompleteNum() / dataMonth.getTotalNum() * 100; |
|
|
|
|
dataMonth.setProcessingRate(b); |
|
|
|
|
} |
|
|
|
|
bladeRedis.setEx(monthKey, dataMonth, 3600L); |
|
|
|
|
} |
|
|
|
|
monthDataList.add(dataMonth); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (!dayDataList.isEmpty()) { |
|
|
|
|
map.put("dayData", dayDataList); |
|
|
|
|
} |
|
|
|
|
if (!monthDataList.isEmpty()) { |
|
|
|
|
map.put("monthData", monthDataList); |
|
|
|
|
} |
|
|
|
|
return map; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private List<IndexHandOrderDataByWarehouseIdVO> buildIndexHandOrderDataByWarehouseIdVO(List<IndexHandOrderDataByWarehouseIdVO> indexHandOrderDataByWarehouseIdVO, List<WarehouseNumberVO> stockNumberDataByWarehouseIdVO, List<WarehouseNumberVO> trayNumList) { |
|
|
|
|
for (IndexHandOrderDataByWarehouseIdVO indexHandOrderDataByWarehouseIdVO1 : indexHandOrderDataByWarehouseIdVO) { |
|
|
|
|
WarehouseNumberVO warehouseNumberVO1 = stockNumberDataByWarehouseIdVO.stream().filter(warehouseNumberVO -> warehouseNumberVO.getWarehouseId().equals(indexHandOrderDataByWarehouseIdVO1.getWarehouseId())).findFirst().orElse(null); |
|
|
|
|