From 1ccb567bd44077e345114ea1e3f6ed29ca3c8a34 Mon Sep 17 00:00:00 2001 From: PigBaoBei <2739175034@qq.com> Date: Tue, 3 Dec 2024 17:25:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E7=9C=8B=E6=9D=BF=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E6=95=B0=E6=8D=AE=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/WarehouseIndexController.java | 22 +++++++ .../report/mapper/WarehouseIndexMapper.java | 20 ++++-- .../report/mapper/WarehouseIndexMapper.xml | 50 +++++++++++++++ .../service/IWarehouseIndexService.java | 7 +++ .../impl/WarehouseIndexServiceImpl.java | 63 +++++++++++++++++++ .../logpm/report/vo/IndexAftersalesVO.java | 44 +++++++++++++ 6 files changed, 202 insertions(+), 4 deletions(-) create mode 100644 blade-service/logpm-report/src/main/java/com/logpm/report/vo/IndexAftersalesVO.java diff --git a/blade-service/logpm-report/src/main/java/com/logpm/report/controller/WarehouseIndexController.java b/blade-service/logpm-report/src/main/java/com/logpm/report/controller/WarehouseIndexController.java index 88460f812..184e975db 100644 --- a/blade-service/logpm-report/src/main/java/com/logpm/report/controller/WarehouseIndexController.java +++ b/blade-service/logpm-report/src/main/java/com/logpm/report/controller/WarehouseIndexController.java @@ -330,4 +330,26 @@ public class WarehouseIndexController { } + @ResponseBody + @GetMapping("/aftersalesData") + @ApiOperationSupport(order = 1) + @ApiOperation(value = "卸车异常数据", notes = "传入indexDTO") + public R aftersalesData() { + String method = "###########aftersalesData: "; + try { + List warehouseIds = warehouseClient.getWarehouseIds(); + + //查询订制品打托列表 + Map> map = warehouseIndexService.aftersalesData(warehouseIds); + return R.data(map); + } catch (CustomerException e) { + log.warn(e.message); + return R.fail(e.code, e.message); + } catch (Exception e) { + log.error(method + "系统异常,联系管理员", e); + return R.fail(500, "系统异常,联系管理员"); + } + } + + } diff --git a/blade-service/logpm-report/src/main/java/com/logpm/report/mapper/WarehouseIndexMapper.java b/blade-service/logpm-report/src/main/java/com/logpm/report/mapper/WarehouseIndexMapper.java index 0b3987439..35b0530a9 100644 --- a/blade-service/logpm-report/src/main/java/com/logpm/report/mapper/WarehouseIndexMapper.java +++ b/blade-service/logpm-report/src/main/java/com/logpm/report/mapper/WarehouseIndexMapper.java @@ -2,10 +2,7 @@ package com.logpm.report.mapper; import com.alibaba.fastjson.JSONObject; import com.logpm.report.dto.IndexDTO; -import com.logpm.report.vo.IndexHandOrderDataByWarehouseIdVO; -import com.logpm.report.vo.IndexHandOrderDataVO; -import com.logpm.report.vo.IndexTrunklineCarsDataVO; -import com.logpm.report.vo.WarehouseNumberVO; +import com.logpm.report.vo.*; import com.logpm.report.vo.indexCount.IndexDeliveryDataVO; import com.logpm.report.vo.indexCount.IndexOpenItemDataByWarWarehouseIdVO; import com.logpm.report.vo.indexCount.IndexOpenItemDataVO; @@ -14,6 +11,7 @@ import org.apache.ibatis.annotations.Param; import java.math.BigDecimal; import java.util.List; +import java.util.Map; @Mapper public interface WarehouseIndexMapper { @@ -362,4 +360,18 @@ public interface WarehouseIndexMapper { List findTripartiteDeliveryTotal(@Param("param")IndexDTO indexDTO); String findBillLadingOverTimeNumByMonth(@Param("warehouseId")Long warehouseId); + + /** + * 查询异常每天的数据 + * @param warehouseId + * @return + */ + IndexAftersalesVO findAftersalesDataByDay(@Param("warehouseId")Long warehouseId); + + /** + * 查询异常每月的数据 + * @param warehouseId + * @return + */ + IndexAftersalesVO findAftersalesDataByMonth(@Param("warehouseId")Long warehouseId); } diff --git a/blade-service/logpm-report/src/main/java/com/logpm/report/mapper/WarehouseIndexMapper.xml b/blade-service/logpm-report/src/main/java/com/logpm/report/mapper/WarehouseIndexMapper.xml index faa5be5e3..005e08099 100644 --- a/blade-service/logpm-report/src/main/java/com/logpm/report/mapper/WarehouseIndexMapper.xml +++ b/blade-service/logpm-report/src/main/java/com/logpm/report/mapper/WarehouseIndexMapper.xml @@ -974,6 +974,56 @@ AND warehouse_id = #{warehouseId} + + diff --git a/blade-service/logpm-report/src/main/java/com/logpm/report/service/IWarehouseIndexService.java b/blade-service/logpm-report/src/main/java/com/logpm/report/service/IWarehouseIndexService.java index 3ef88c3a8..be9227170 100644 --- a/blade-service/logpm-report/src/main/java/com/logpm/report/service/IWarehouseIndexService.java +++ b/blade-service/logpm-report/src/main/java/com/logpm/report/service/IWarehouseIndexService.java @@ -42,4 +42,11 @@ public interface IWarehouseIndexService { List allocationDataByWarehouseId(IndexDTO indexDTO); List handOrderDataByWarehouseId(IndexDTO indexDTO); + + /** + * 首页查询售后数据 + * @param warehouseIds + * @return + */ + Map> aftersalesData(List warehouseIds); } diff --git a/blade-service/logpm-report/src/main/java/com/logpm/report/service/impl/WarehouseIndexServiceImpl.java b/blade-service/logpm-report/src/main/java/com/logpm/report/service/impl/WarehouseIndexServiceImpl.java index e0a71d42f..e93bad557 100644 --- a/blade-service/logpm-report/src/main/java/com/logpm/report/service/impl/WarehouseIndexServiceImpl.java +++ b/blade-service/logpm-report/src/main/java/com/logpm/report/service/impl/WarehouseIndexServiceImpl.java @@ -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> aftersalesData(List warehouseIds) { + BladeUser user = AuthUtil.getUser(); + List dayDataList = new ArrayList<>(); + List monthDataList = new ArrayList<>(); + Map> 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 buildIndexHandOrderDataByWarehouseIdVO(List indexHandOrderDataByWarehouseIdVO, List stockNumberDataByWarehouseIdVO, List trayNumList) { for (IndexHandOrderDataByWarehouseIdVO indexHandOrderDataByWarehouseIdVO1 : indexHandOrderDataByWarehouseIdVO) { WarehouseNumberVO warehouseNumberVO1 = stockNumberDataByWarehouseIdVO.stream().filter(warehouseNumberVO -> warehouseNumberVO.getWarehouseId().equals(indexHandOrderDataByWarehouseIdVO1.getWarehouseId())).findFirst().orElse(null); diff --git a/blade-service/logpm-report/src/main/java/com/logpm/report/vo/IndexAftersalesVO.java b/blade-service/logpm-report/src/main/java/com/logpm/report/vo/IndexAftersalesVO.java new file mode 100644 index 000000000..eb229b474 --- /dev/null +++ b/blade-service/logpm-report/src/main/java/com/logpm/report/vo/IndexAftersalesVO.java @@ -0,0 +1,44 @@ +package com.logpm.report.vo; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.annotation.write.style.ColumnWidth; +import com.alibaba.excel.annotation.write.style.ContentRowHeight; +import com.alibaba.excel.annotation.write.style.HeadRowHeight; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +/** + * 库存品表 vo + * + * @author zhaoqiaobo + * @create 2024-03-06 16:02 + */ +@ColumnWidth(25) +@HeadRowHeight(20) +@ContentRowHeight(18) +@ApiModel(value = "首页异常数据", description = "首页异常数据") +@Data +public class IndexAftersalesVO implements Serializable { + + private static final long serialVersionUID = 1L; + + @ExcelProperty("仓库") + private String warehouseName; + + @ExcelProperty("总数量") + private Integer totalNum; + + @ExcelProperty("未完成数量") + private Integer unCompleteNum; + + @ExcelProperty("完成数量") + private Integer completeNum; + + + @ExcelProperty("完成数量") + private double processingRate; + +}