Browse Source

数据看板异常数据接口

fix-sign
汤建军 4 months ago
parent
commit
1ccb567bd4
  1. 22
      blade-service/logpm-report/src/main/java/com/logpm/report/controller/WarehouseIndexController.java
  2. 20
      blade-service/logpm-report/src/main/java/com/logpm/report/mapper/WarehouseIndexMapper.java
  3. 50
      blade-service/logpm-report/src/main/java/com/logpm/report/mapper/WarehouseIndexMapper.xml
  4. 7
      blade-service/logpm-report/src/main/java/com/logpm/report/service/IWarehouseIndexService.java
  5. 63
      blade-service/logpm-report/src/main/java/com/logpm/report/service/impl/WarehouseIndexServiceImpl.java
  6. 44
      blade-service/logpm-report/src/main/java/com/logpm/report/vo/IndexAftersalesVO.java

22
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<Long> warehouseIds = warehouseClient.getWarehouseIds();
//查询订制品打托列表
Map<String,List<IndexAftersalesVO>> 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, "系统异常,联系管理员");
}
}
}

20
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<IndexDeliveryDataVO> 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);
}

50
blade-service/logpm-report/src/main/java/com/logpm/report/mapper/WarehouseIndexMapper.xml

@ -974,6 +974,56 @@
AND warehouse_id = #{warehouseId}
</where>
</select>
<select id="findAftersalesDataByDay" resultType="com.logpm.report.vo.IndexAftersalesVO">
SELECT
lawo.warehouse_name AS warehouseName,
IFNUll(count( 1 ),0) AS totalNum,
(
SELECT
count( 1 )
FROM
logpm_aftersales_work_order AS lbwo
WHERE
lbwo.is_deleted = 0
AND lbwo.warehouse_id = lawo.warehouse_id
AND lbwo.work_order_status NOT IN (80,100,110)
AND DATE_FORMAT( lbwo.create_time, '%y%m%d' ) = DATE_FORMAT( NOW(), '%y%m%d' )
) AS unCompleteNum
FROM
logpm_aftersales_work_order AS lawo
<where>
lawo.is_deleted = 0
AND DATE_FORMAT( lawo.create_time, '%y%m%d' ) = DATE_FORMAT( NOW(), '%y%m%d' )
AND lawo.warehouse_id = #{warehouseId}
GROUP BY
lawo.warehouse_id
</where>
</select>
<select id="findAftersalesDataByMonth" resultType="com.logpm.report.vo.IndexAftersalesVO">
SELECT
lawo.warehouse_name AS warehouseName,
IFNUll(count( 1 ),0) AS totalNum,
(
SELECT
count( 1 )
FROM
logpm_aftersales_work_order AS lbwo
WHERE
lbwo.is_deleted = 0
AND lbwo.warehouse_id = lawo.warehouse_id
AND lbwo.work_order_status NOT IN (80,100,110)
AND DATE_FORMAT( lbwo.create_time, '%y%m%d' ) = DATE_FORMAT( NOW(), '%y%m%d' )
) AS unCompleteNum
FROM
logpm_aftersales_work_order AS lawo
<where>
lawo.is_deleted = 0
AND DATE_FORMAT( lawo.create_time, '%y%m' ) = DATE_FORMAT( NOW(), '%y%m' )
AND lawo.warehouse_id = #{warehouseId}
GROUP BY
lawo.warehouse_id
</where>
</select>
</mapper>

7
blade-service/logpm-report/src/main/java/com/logpm/report/service/IWarehouseIndexService.java

@ -42,4 +42,11 @@ public interface IWarehouseIndexService {
List<IndexAllocationDataByWarehouseIdVO> allocationDataByWarehouseId(IndexDTO indexDTO);
List<IndexHandOrderDataByWarehouseIdVO> handOrderDataByWarehouseId(IndexDTO indexDTO);
/**
* 首页查询售后数据
* @param warehouseIds
* @return
*/
Map<String,List<IndexAftersalesVO>> aftersalesData(List<Long> warehouseIds);
}

63
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<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);

44
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;
}
Loading…
Cancel
Save