大屏显示处理
This commit is contained in:
parent
eff95f15fd
commit
4145b630b9
|
|
@ -23,10 +23,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
import static com.wms.utils.StringUtils.convertJsonString;
|
import static com.wms.utils.StringUtils.convertJsonString;
|
||||||
|
|
||||||
|
|
@ -42,7 +39,6 @@ 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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 请求库位使用情况
|
* 请求库位使用情况
|
||||||
* @return 库位使用情况
|
* @return 库位使用情况
|
||||||
|
|
@ -52,15 +48,19 @@ public class MonitorController {
|
||||||
public String getLocationUseDetail() {
|
public String getLocationUseDetail() {
|
||||||
LocationUseDetail response = new LocationUseDetail();
|
LocationUseDetail response = new LocationUseDetail();
|
||||||
try {
|
try {
|
||||||
int allSize = (int) locationService.count();
|
// //总库位
|
||||||
int emptySize = (int) locationService.count(new LambdaQueryWrapper<Location>()
|
// int allSize = (int) locationService.count();
|
||||||
.eq(Location::getIsLock, 0)
|
// //空库位
|
||||||
.eq(Location::getLocationStatus, 0));
|
// int emptySize = (int) locationService.count(new LambdaQueryWrapper<Location>()
|
||||||
response.setUsed(allSize - emptySize);
|
// .eq(Location::getIsLock, 0)
|
||||||
response.setEmpty(emptySize);
|
// .eq(Location::getLocationStatus, 0));
|
||||||
|
response = locationService.statisticLocationList();
|
||||||
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
response.setUsed(0);
|
response.setUsed(0);
|
||||||
response.setEmpty(0);
|
response.setEmpty(0);
|
||||||
|
response.setEmptyUsed(0);
|
||||||
}
|
}
|
||||||
return convertJsonString(response);
|
return convertJsonString(response);
|
||||||
}
|
}
|
||||||
|
|
@ -72,18 +72,47 @@ public class MonitorController {
|
||||||
@GetMapping("/getAnalysis7Days")
|
@GetMapping("/getAnalysis7Days")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String getAnalysis7Days() {
|
public String getAnalysis7Days() {
|
||||||
|
//记录开始时间戳
|
||||||
|
long startTime = System.currentTimeMillis();
|
||||||
|
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();
|
||||||
try {
|
try {
|
||||||
// 获取当前日期
|
// 获取当前日期
|
||||||
LocalDate now = LocalDate.now();
|
// LocalDate now = LocalDate.now();
|
||||||
// 创建一个列表来存储日期
|
// 创建一个列表来存储日期
|
||||||
List<LocalDate> dates = new ArrayList<>();
|
// List<LocalDate> dates = new ArrayList<>();
|
||||||
// 添加最近7天的日期到列表中
|
|
||||||
for (int i = 6; i >= 0; i--) {
|
//List<WorkSummary> allWorkSummaries = workSummaryService.list();
|
||||||
dates.add(now.minusDays(i));
|
List<LocalDate> workDays = workSummaryService.getRecentWorkDays(); //
|
||||||
|
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){
|
||||||
|
param.put("endDate", workDays.get(0));
|
||||||
|
}else {
|
||||||
|
param.put("endDate", workDays.get(workDays.size() - 1));
|
||||||
}
|
}
|
||||||
|
List<WorkSummary> allWorkSummaries = workSummaryService.getByWorkDays(param);
|
||||||
|
// int dayOffset = 0;
|
||||||
|
// while (dates.size() < 7) {
|
||||||
|
// LocalDate targetDate = now.minusDays(dayOffset++);
|
||||||
|
// List<WorkSummary> dayWorkSummaryList = allWorkSummaries.stream()
|
||||||
|
// .filter(ws -> Objects.equals(ws.getWorkDate().toLocalDate(), targetDate))
|
||||||
|
// .toList();
|
||||||
|
//
|
||||||
|
// long totalCount = dayWorkSummaryList.size();
|
||||||
|
// if (totalCount > 0) {
|
||||||
|
// dates.add(0, targetDate); // 注意插入头部,保持时间顺序
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// 添加最近7天的日期到列表中
|
||||||
|
// for (int i = 6; i >= 0; i--) {
|
||||||
|
// dates.add(now.minusDays(i));
|
||||||
|
// }
|
||||||
|
|
||||||
// 9个站台的信息
|
// 9个站台的信息
|
||||||
List<Integer> stand1 = new ArrayList<>();
|
List<Integer> stand1 = new ArrayList<>();
|
||||||
List<Integer> stand2 = new ArrayList<>();
|
List<Integer> stand2 = new ArrayList<>();
|
||||||
|
|
@ -95,9 +124,8 @@ public class MonitorController {
|
||||||
List<Integer> stand8 = new ArrayList<>();
|
List<Integer> stand8 = new ArrayList<>();
|
||||||
List<Integer> stand9 = new ArrayList<>();
|
List<Integer> stand9 = new ArrayList<>();
|
||||||
// 获取所有的工作总结
|
// 获取所有的工作总结
|
||||||
List<WorkSummary> allWorkSummaries = workSummaryService.list();
|
|
||||||
// 循环日期
|
// 循环日期
|
||||||
for (LocalDate date : dates) {
|
for (LocalDate date : workDays) {
|
||||||
dateList.add(date.format(DateTimeFormatter.ofPattern("MM-dd")));
|
dateList.add(date.format(DateTimeFormatter.ofPattern("MM-dd")));
|
||||||
// 获取当日的工作总结
|
// 获取当日的工作总结
|
||||||
List<WorkSummary> dayWorkSummaryList = allWorkSummaries.stream().filter(workSummary -> Objects.equals(workSummary.getWorkDate().toLocalDate(), date)).toList();
|
List<WorkSummary> dayWorkSummaryList = allWorkSummaries.stream().filter(workSummary -> Objects.equals(workSummary.getWorkDate().toLocalDate(), date)).toList();
|
||||||
|
|
@ -145,6 +173,9 @@ public class MonitorController {
|
||||||
}
|
}
|
||||||
response.setWorks(works);
|
response.setWorks(works);
|
||||||
response.setDate(dateList);
|
response.setDate(dateList);
|
||||||
|
//记录总用时
|
||||||
|
long totalTime = System.currentTimeMillis() - startTime;
|
||||||
|
System.out.println("总用时:" + totalTime);
|
||||||
return convertJsonString(response);
|
return convertJsonString(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,13 +6,19 @@ import lombok.Data;
|
||||||
@Data
|
@Data
|
||||||
public class LocationUseDetail {
|
public class LocationUseDetail {
|
||||||
/**
|
/**
|
||||||
* 占用
|
* 有货占用
|
||||||
*/
|
*/
|
||||||
@JsonProperty("used")
|
@JsonProperty("used")
|
||||||
private Integer used;
|
private Integer used;
|
||||||
/**
|
/**
|
||||||
* 空闲
|
* 空库位
|
||||||
*/
|
*/
|
||||||
@JsonProperty("empty")
|
@JsonProperty("empty")
|
||||||
private Integer empty;
|
private Integer empty;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 空托盘占用
|
||||||
|
*/
|
||||||
|
@JsonProperty("emptyUsed")
|
||||||
|
private Integer emptyUsed;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,12 @@
|
||||||
package com.wms.mapper;
|
package com.wms.mapper;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.wms.entity.app.monitor.LocationUseDetail;
|
||||||
import com.wms.entity.table.Location;
|
import com.wms.entity.table.Location;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface LocationMapper extends BaseMapper<Location> {
|
public interface LocationMapper extends BaseMapper<Location> {
|
||||||
|
|
||||||
|
LocationUseDetail statisticLocationList();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,17 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.wms.entity.table.WorkSummary;
|
import com.wms.entity.table.WorkSummary;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 工作总结mapper
|
* 工作总结mapper
|
||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface WorkSummaryMapper extends BaseMapper<WorkSummary> {
|
public interface WorkSummaryMapper extends BaseMapper<WorkSummary> {
|
||||||
|
|
||||||
}
|
List<LocalDate> getRecentWorkDays();
|
||||||
|
|
||||||
|
List<WorkSummary> getByWorkDays(Map<String,Object> params);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.wms.service;
|
package com.wms.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.wms.entity.app.monitor.LocationUseDetail;
|
||||||
import com.wms.entity.table.Location;
|
import com.wms.entity.table.Location;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
@ -17,4 +18,6 @@ public interface LocationService extends IService<Location> {
|
||||||
* @return 结果 nextLocationId, preTaskId
|
* @return 结果 nextLocationId, preTaskId
|
||||||
*/
|
*/
|
||||||
Map<String, String> getOneLocation(String inPoint, String vehicleId, String goodsId);
|
Map<String, String> getOneLocation(String inPoint, String vehicleId, String goodsId);
|
||||||
|
|
||||||
|
LocationUseDetail statisticLocationList();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,15 @@ package com.wms.service;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.wms.entity.table.WorkSummary;
|
import com.wms.entity.table.WorkSummary;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 工作总结服务接口
|
* 工作总结服务接口
|
||||||
*/
|
*/
|
||||||
public interface WorkSummaryService extends IService<WorkSummary> {
|
public interface WorkSummaryService extends IService<WorkSummary> {
|
||||||
|
List<LocalDate> getRecentWorkDays();
|
||||||
|
|
||||||
|
List<WorkSummary> getByWorkDays(Map<String,Object> params);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.wms.constants.enums.StockStatus;
|
import com.wms.constants.enums.StockStatus;
|
||||||
import com.wms.constants.enums.TaskType;
|
import com.wms.constants.enums.TaskType;
|
||||||
import com.wms.constants.enums.WmsTaskStatus;
|
import com.wms.constants.enums.WmsTaskStatus;
|
||||||
|
import com.wms.entity.app.monitor.LocationUseDetail;
|
||||||
import com.wms.entity.table.*;
|
import com.wms.entity.table.*;
|
||||||
import com.wms.mapper.*;
|
import com.wms.mapper.*;
|
||||||
import com.wms.service.LocationService;
|
import com.wms.service.LocationService;
|
||||||
|
|
@ -146,6 +147,11 @@ public class LocationServiceImplements extends ServiceImpl<LocationMapper, Locat
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LocationUseDetail statisticLocationList() {
|
||||||
|
return locationMapper.statisticLocationList();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据设备号查找库位
|
* 根据设备号查找库位
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -8,10 +8,25 @@ import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 工作总结服务实现
|
* 工作总结服务实现
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||||
public class WorkSummaryServiceImpl extends ServiceImpl<WorkSummaryMapper, WorkSummary> implements WorkSummaryService {
|
public class WorkSummaryServiceImpl extends ServiceImpl<WorkSummaryMapper, WorkSummary> implements WorkSummaryService {
|
||||||
|
@Autowired
|
||||||
|
private WorkSummaryMapper workSummaryMapper;
|
||||||
|
@Override
|
||||||
|
public List<LocalDate> getRecentWorkDays() {
|
||||||
|
return workSummaryMapper.getRecentWorkDays();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<WorkSummary> getByWorkDays(Map<String,Object> params) {
|
||||||
|
return workSummaryMapper.getByWorkDays(params);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,5 +2,33 @@
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
"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
|
||||||
|
-- 空库位(没有载具)
|
||||||
|
SUM(CASE WHEN loc.location_status = 0 THEN 1 ELSE 0 END) AS `empty`,
|
||||||
|
|
||||||
</mapper>
|
-- 有货的载具(location_status = 1 且 vehicle_id 存在于 stock 表中)
|
||||||
|
SUM(CASE
|
||||||
|
WHEN loc.location_status = 1
|
||||||
|
AND EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM tbl_app_stock stock
|
||||||
|
WHERE stock.vehicle_id = loc.vehicle_id
|
||||||
|
) THEN 1
|
||||||
|
ELSE 0
|
||||||
|
END) AS used,
|
||||||
|
|
||||||
|
-- 空载具(location_status = 1 且 vehicle_id 在 stock 表中找不到)
|
||||||
|
SUM(CASE
|
||||||
|
WHEN loc.location_status = 1
|
||||||
|
AND NOT EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM tbl_app_stock stock
|
||||||
|
WHERE stock.vehicle_id = loc.vehicle_id
|
||||||
|
) THEN 1
|
||||||
|
ELSE 0
|
||||||
|
END) AS emptyUsed
|
||||||
|
|
||||||
|
FROM tbl_app_location loc;
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
|
|
|
||||||
|
|
@ -2,5 +2,21 @@
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
"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 DISTINCT DATE(work_date) AS work_day
|
||||||
|
FROM tbl_app_work_summary
|
||||||
|
ORDER BY DATE(work_date) DESC
|
||||||
|
LIMIT 7
|
||||||
|
|
||||||
</mapper>
|
</select>
|
||||||
|
<select id="getByWorkDays" resultType="com.wms.entity.table.WorkSummary" parameterType="java.util.Map" >
|
||||||
|
SELECT
|
||||||
|
work_station as "workStation",
|
||||||
|
work_date as "workDate"
|
||||||
|
FROM
|
||||||
|
tbl_app_work_summary
|
||||||
|
WHERE
|
||||||
|
work_date BETWEEN #{startDate} AND #{endDate}
|
||||||
|
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user