大屏优化

This commit is contained in:
bo.wu@finesys.com.cn 2025-05-20 15:09:18 +08:00
parent 75a96e9880
commit bf7e90bdf1
3 changed files with 34 additions and 22 deletions

View File

@ -5,14 +5,8 @@ import com.wms.entity.app.monitor.Analysis7Days;
import com.wms.entity.app.monitor.FinishDetail;
import com.wms.entity.app.monitor.LocationUseDetail;
import com.wms.entity.app.monitor.WorkInfoByStand;
import com.wms.entity.table.Location;
import com.wms.entity.table.Stand;
import com.wms.entity.table.WorkFlow;
import com.wms.entity.table.WorkSummary;
import com.wms.service.LocationService;
import com.wms.service.StandService;
import com.wms.service.WorkFlowService;
import com.wms.service.WorkSummaryService;
import com.wms.entity.table.*;
import com.wms.service.*;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
@ -22,8 +16,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.time.LocalDate;
import java.time.chrono.ChronoLocalDate;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
import static com.wms.utils.StringUtils.convertJsonString;
@ -39,6 +35,7 @@ public class MonitorController {
private final WorkFlowService workFlowService;
private final WorkSummaryService workSummaryService;
private final StandService standService;
private final StockService stockService;
/**
* 请求库位使用情况
* @return 库位使用情况
@ -46,15 +43,24 @@ public class MonitorController {
@GetMapping("/getLocationUseDetail")
@ResponseBody
public String getLocationUseDetail() {
//开始时间
long l = System.currentTimeMillis();
LocationUseDetail response = new LocationUseDetail();
try {
// //总库位
// int allSize = (int) locationService.count();
// //空库位
// int emptySize = (int) locationService.count(new LambdaQueryWrapper<Location>()
// .eq(Location::getIsLock, 0)
// .eq(Location::getLocationStatus, 0));
response = locationService.statisticLocationList();
int allSize = (int) locationService.count();
//空库位
int emptySize = (int) locationService.count(new LambdaQueryWrapper<Location>()
.eq(Location::getIsLock, 0)
.eq(Location::getLocationStatus, 0));
//查询所有库存
List<Stock> stockList = stockService.list();
//根据库存去重库位
long count = stockList.stream().map(Stock::getLocationId).distinct().count();
response.setEmpty(emptySize);
response.setUsed((int) count);
response.setEmptyUsed(allSize - emptySize - response.getUsed());
// response = locationService.statisticLocationList();
} catch (Exception e) {
@ -62,6 +68,7 @@ public class MonitorController {
response.setEmpty(0);
response.setEmptyUsed(0);
}
System.out.println("结束执行getLocationUseDetail方法:"+(System.currentTimeMillis()-l));
return convertJsonString(response);
}
@ -73,8 +80,8 @@ public class MonitorController {
@ResponseBody
public String getAnalysis7Days() {
//记录开始时间戳
long startTime = System.currentTimeMillis();
System.out.println("开始执行getAnalysis7Days方法:"+startTime);
// long startTime = System.currentTimeMillis();
// System.out.println("开始执行getAnalysis7Days方法:"+startTime);
Analysis7Days response = new Analysis7Days();
List<String> dateList = new ArrayList<>();
WorkInfoByStand works = new WorkInfoByStand();
@ -86,8 +93,9 @@ public class MonitorController {
//List<WorkSummary> allWorkSummaries = workSummaryService.list();
List<LocalDate> workDays = workSummaryService.getRecentWorkDays(); //
// long totalTime = System.currentTimeMillis() - startTime;
// System.out.println("总用时1" + totalTime);
Collections.reverse(workDays);
// List<WorkSummary> allWorkSummaries = workSummaryService.getByWorkDays(workDays);
Map<String, Object> param = new HashMap<>();
param.put("startDate", workDays.get(0));
if(workDays.size() == 1){
@ -96,6 +104,8 @@ public class MonitorController {
param.put("endDate", workDays.get(workDays.size() - 1));
}
List<WorkSummary> allWorkSummaries = workSummaryService.getByWorkDays(param);
// long totalTime2 = System.currentTimeMillis() - startTime;
// System.out.println("总用时2" + totalTime2);
// int dayOffset = 0;
// while (dates.size() < 7) {
// LocalDate targetDate = now.minusDays(dayOffset++);
@ -174,8 +184,8 @@ public class MonitorController {
response.setWorks(works);
response.setDate(dateList);
//记录总用时
long totalTime = System.currentTimeMillis() - startTime;
System.out.println("总用时:" + totalTime);
// long totalTime3 = System.currentTimeMillis() - startTime;
// System.out.println("总用时:" + totalTime3);
return convertJsonString(response);
}

View File

@ -3,6 +3,7 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.wms.mapper.LocationMapper">
<select id="statisticLocationList" resultType="com.wms.entity.app.monitor.LocationUseDetail">
-- 这个代码耗时太长,先不用了
SELECT
-- 空库位(没有载具)
SUM(CASE WHEN loc.location_status = 0 THEN 1 ELSE 0 END) AS `empty`,

View File

@ -3,10 +3,11 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.wms.mapper.WorkSummaryMapper">
<select id="getRecentWorkDays" resultType="java.time.LocalDate">
SELECT DISTINCT DATE(work_date) AS work_day
SELECT CAST(work_date AS DATE) AS work_day
FROM tbl_app_work_summary
ORDER BY DATE(work_date) DESC
LIMIT 7
GROUP BY work_day
ORDER BY work_day DESC
LIMIT 7;
</select>
<select id="getByWorkDays" resultType="com.wms.entity.table.WorkSummary" parameterType="java.util.Map" >