大屏优化
This commit is contained in:
parent
75a96e9880
commit
bf7e90bdf1
|
|
@ -5,14 +5,8 @@ import com.wms.entity.app.monitor.Analysis7Days;
|
||||||
import com.wms.entity.app.monitor.FinishDetail;
|
import com.wms.entity.app.monitor.FinishDetail;
|
||||||
import com.wms.entity.app.monitor.LocationUseDetail;
|
import com.wms.entity.app.monitor.LocationUseDetail;
|
||||||
import com.wms.entity.app.monitor.WorkInfoByStand;
|
import com.wms.entity.app.monitor.WorkInfoByStand;
|
||||||
import com.wms.entity.table.Location;
|
import com.wms.entity.table.*;
|
||||||
import com.wms.entity.table.Stand;
|
import com.wms.service.*;
|
||||||
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 lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
|
|
@ -22,8 +16,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
import java.time.chrono.ChronoLocalDate;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static com.wms.utils.StringUtils.convertJsonString;
|
import static com.wms.utils.StringUtils.convertJsonString;
|
||||||
|
|
||||||
|
|
@ -39,6 +35,7 @@ public class MonitorController {
|
||||||
private final WorkFlowService workFlowService;
|
private final WorkFlowService workFlowService;
|
||||||
private final WorkSummaryService workSummaryService;
|
private final WorkSummaryService workSummaryService;
|
||||||
private final StandService standService;
|
private final StandService standService;
|
||||||
|
private final StockService stockService;
|
||||||
/**
|
/**
|
||||||
* 请求库位使用情况
|
* 请求库位使用情况
|
||||||
* @return 库位使用情况
|
* @return 库位使用情况
|
||||||
|
|
@ -46,15 +43,24 @@ public class MonitorController {
|
||||||
@GetMapping("/getLocationUseDetail")
|
@GetMapping("/getLocationUseDetail")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String getLocationUseDetail() {
|
public String getLocationUseDetail() {
|
||||||
|
//开始时间
|
||||||
|
long l = System.currentTimeMillis();
|
||||||
LocationUseDetail response = new LocationUseDetail();
|
LocationUseDetail response = new LocationUseDetail();
|
||||||
try {
|
try {
|
||||||
// //总库位
|
// //总库位
|
||||||
// int allSize = (int) locationService.count();
|
int allSize = (int) locationService.count();
|
||||||
// //空库位
|
//空库位
|
||||||
// int emptySize = (int) locationService.count(new LambdaQueryWrapper<Location>()
|
int emptySize = (int) locationService.count(new LambdaQueryWrapper<Location>()
|
||||||
// .eq(Location::getIsLock, 0)
|
.eq(Location::getIsLock, 0)
|
||||||
// .eq(Location::getLocationStatus, 0));
|
.eq(Location::getLocationStatus, 0));
|
||||||
response = locationService.statisticLocationList();
|
//查询所有库存
|
||||||
|
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) {
|
} catch (Exception e) {
|
||||||
|
|
@ -62,6 +68,7 @@ public class MonitorController {
|
||||||
response.setEmpty(0);
|
response.setEmpty(0);
|
||||||
response.setEmptyUsed(0);
|
response.setEmptyUsed(0);
|
||||||
}
|
}
|
||||||
|
System.out.println("结束执行getLocationUseDetail方法:"+(System.currentTimeMillis()-l));
|
||||||
return convertJsonString(response);
|
return convertJsonString(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -73,8 +80,8 @@ public class MonitorController {
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String getAnalysis7Days() {
|
public String getAnalysis7Days() {
|
||||||
//记录开始时间戳
|
//记录开始时间戳
|
||||||
long startTime = System.currentTimeMillis();
|
// long startTime = System.currentTimeMillis();
|
||||||
System.out.println("开始执行getAnalysis7Days方法:"+startTime);
|
// System.out.println("开始执行getAnalysis7Days方法:"+startTime);
|
||||||
Analysis7Days response = new Analysis7Days();
|
Analysis7Days response = new Analysis7Days();
|
||||||
List<String> dateList = new ArrayList<>();
|
List<String> dateList = new ArrayList<>();
|
||||||
WorkInfoByStand works = new WorkInfoByStand();
|
WorkInfoByStand works = new WorkInfoByStand();
|
||||||
|
|
@ -86,8 +93,9 @@ public class MonitorController {
|
||||||
|
|
||||||
//List<WorkSummary> allWorkSummaries = workSummaryService.list();
|
//List<WorkSummary> allWorkSummaries = workSummaryService.list();
|
||||||
List<LocalDate> workDays = workSummaryService.getRecentWorkDays(); //
|
List<LocalDate> workDays = workSummaryService.getRecentWorkDays(); //
|
||||||
|
// long totalTime = System.currentTimeMillis() - startTime;
|
||||||
|
// System.out.println("总用时1:" + totalTime);
|
||||||
Collections.reverse(workDays);
|
Collections.reverse(workDays);
|
||||||
// List<WorkSummary> allWorkSummaries = workSummaryService.getByWorkDays(workDays);
|
|
||||||
Map<String, Object> param = new HashMap<>();
|
Map<String, Object> param = new HashMap<>();
|
||||||
param.put("startDate", workDays.get(0));
|
param.put("startDate", workDays.get(0));
|
||||||
if(workDays.size() == 1){
|
if(workDays.size() == 1){
|
||||||
|
|
@ -96,6 +104,8 @@ public class MonitorController {
|
||||||
param.put("endDate", workDays.get(workDays.size() - 1));
|
param.put("endDate", workDays.get(workDays.size() - 1));
|
||||||
}
|
}
|
||||||
List<WorkSummary> allWorkSummaries = workSummaryService.getByWorkDays(param);
|
List<WorkSummary> allWorkSummaries = workSummaryService.getByWorkDays(param);
|
||||||
|
// long totalTime2 = System.currentTimeMillis() - startTime;
|
||||||
|
// System.out.println("总用时2:" + totalTime2);
|
||||||
// int dayOffset = 0;
|
// int dayOffset = 0;
|
||||||
// while (dates.size() < 7) {
|
// while (dates.size() < 7) {
|
||||||
// LocalDate targetDate = now.minusDays(dayOffset++);
|
// LocalDate targetDate = now.minusDays(dayOffset++);
|
||||||
|
|
@ -174,8 +184,8 @@ public class MonitorController {
|
||||||
response.setWorks(works);
|
response.setWorks(works);
|
||||||
response.setDate(dateList);
|
response.setDate(dateList);
|
||||||
//记录总用时
|
//记录总用时
|
||||||
long totalTime = System.currentTimeMillis() - startTime;
|
// long totalTime3 = System.currentTimeMillis() - startTime;
|
||||||
System.out.println("总用时:" + totalTime);
|
// System.out.println("总用时:" + totalTime3);
|
||||||
return convertJsonString(response);
|
return convertJsonString(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.wms.mapper.LocationMapper">
|
<mapper namespace="com.wms.mapper.LocationMapper">
|
||||||
<select id="statisticLocationList" resultType="com.wms.entity.app.monitor.LocationUseDetail">
|
<select id="statisticLocationList" resultType="com.wms.entity.app.monitor.LocationUseDetail">
|
||||||
|
-- 这个代码耗时太长,先不用了
|
||||||
SELECT
|
SELECT
|
||||||
-- 空库位(没有载具)
|
-- 空库位(没有载具)
|
||||||
SUM(CASE WHEN loc.location_status = 0 THEN 1 ELSE 0 END) AS `empty`,
|
SUM(CASE WHEN loc.location_status = 0 THEN 1 ELSE 0 END) AS `empty`,
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,11 @@
|
||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.wms.mapper.WorkSummaryMapper">
|
<mapper namespace="com.wms.mapper.WorkSummaryMapper">
|
||||||
<select id="getRecentWorkDays" resultType="java.time.LocalDate">
|
<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
|
FROM tbl_app_work_summary
|
||||||
ORDER BY DATE(work_date) DESC
|
GROUP BY work_day
|
||||||
LIMIT 7
|
ORDER BY work_day DESC
|
||||||
|
LIMIT 7;
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
<select id="getByWorkDays" resultType="com.wms.entity.table.WorkSummary" parameterType="java.util.Map" >
|
<select id="getByWorkDays" resultType="com.wms.entity.table.WorkSummary" parameterType="java.util.Map" >
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user