opt:富佳项目看板优化
This commit is contained in:
@@ -106,6 +106,7 @@
|
||||
ext.frozen_qty,
|
||||
ext.remark,
|
||||
ext.create_time,
|
||||
ext.update_time,
|
||||
attr.struct_code,
|
||||
attr.struct_name,
|
||||
attr.stor_name,
|
||||
|
||||
@@ -24,4 +24,31 @@ public interface StructattrMapper extends BaseMapper<Structattr>{
|
||||
|
||||
BigDecimal calculateSectOccupancyRate(@Param("sect_code")String sect_code);
|
||||
|
||||
JSONObject overview(@Param("stor_code")String stor_code);
|
||||
|
||||
List<JSONObject> locations(@Param("stor_code")String stor_code);
|
||||
|
||||
/**
|
||||
* 获取报表统计数据
|
||||
* @return 包含统计信息的JSON对象
|
||||
*/
|
||||
JSONObject getReportData();
|
||||
|
||||
/**
|
||||
* 获取最近7天的历史数据
|
||||
* @return 历史数据列表
|
||||
*/
|
||||
List<JSONObject> getHistoryData();
|
||||
|
||||
/**
|
||||
* 获取本周任务数据
|
||||
* @return 本周任务统计数据
|
||||
*/
|
||||
JSONObject getThisWeekData();
|
||||
|
||||
/**
|
||||
* 获取上周任务数据
|
||||
* @return 上周任务统计数据
|
||||
*/
|
||||
JSONObject getLastWeekData();
|
||||
}
|
||||
|
||||
@@ -109,4 +109,39 @@
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="overview" resultType="com.alibaba.fastjson.JSONObject">
|
||||
select
|
||||
SUM(CASE WHEN is_used =1 THEN 1 ELSE 0 END) AS totalLocations ,
|
||||
COUNT(DISTINCT SUBSTRING_INDEX(struct_code, '-', 1)) AS totalShelves ,
|
||||
SUM(CASE WHEN is_used =1 and storagevehicle_code is not null THEN 1 ELSE 0 END) AS currentInventory ,
|
||||
SUM(CASE WHEN is_used =1 and storagevehicle_code is null THEN 1 ELSE 0 END) AS availableLocations ,
|
||||
SUM(CASE WHEN is_used =1 and lock_type ='1' THEN 1 ELSE 0 END) AS inboundQuantity ,
|
||||
SUM(CASE WHEN is_used =1 and lock_type ='2' THEN 1 ELSE 0 END) AS outboundQuantity ,
|
||||
SUM(CASE WHEN is_used =1 and lock_type ='3' THEN 1 ELSE 0 END) AS moveToQuantity ,
|
||||
SUM(CASE WHEN is_used =1 and lock_type ='4' THEN 1 ELSE 0 END) AS moveFromQuantity
|
||||
|
||||
from st_ivt_structattr
|
||||
<where>
|
||||
is_used =1 and sect_code <![CDATA[<>]]> 'SSX'
|
||||
<if test="stor_code != null and stor_code != ''">
|
||||
AND stor_code = #{stor_code}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="locations" resultType="com.alibaba.fastjson.JSONObject">
|
||||
select struct_code structCode,SUBSTRING_INDEX(struct_code, '-', 1) shelfCode ,SUBSTRING_INDEX(struct_code, '-0', -1) floor, case when lock_type = 0 and storagevehicle_code is null then '空闲'
|
||||
when lock_type = 0 and storagevehicle_code is not null then '占用'
|
||||
when lock_type =1 then '入库中'
|
||||
when lock_type =2 then '出库中'
|
||||
when lock_type =3 then '移入中'
|
||||
when lock_type =4 then '移出中'
|
||||
when lock_type =9 then '其他占用'
|
||||
ELSE '未知状态' -- 新增默认分支,避免 NULL
|
||||
end status
|
||||
|
||||
from st_ivt_structattr
|
||||
where is_used=1 and sect_code <![CDATA[<>]]> 'SSX'
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -5,18 +5,13 @@ import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.nl.common.base.TableDataInfo;
|
||||
import org.nl.common.logging.annotation.Log;
|
||||
import org.nl.wms.bigscreen_manage.service.BigScreenService;
|
||||
import org.nl.wms.pda_manage.util.PdaResponse;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -43,12 +38,47 @@ public class BigScreenController {
|
||||
@Log("大屏数据")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> getData(@RequestBody JSONObject stors) {
|
||||
String storStr = stors.getString("stors");
|
||||
List<JSONObject> data = new ArrayList<>();
|
||||
if (!StringUtils.isEmpty(storStr)){
|
||||
data = bigScreenService.getData(Arrays.asList(storStr.split(",")));
|
||||
}
|
||||
data = bigScreenService.getData(Arrays.asList("FJ"));
|
||||
|
||||
return new ResponseEntity<>(TableDataInfo.build(data), HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/getDashboardData")
|
||||
@Log("富佳大屏数据")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> getDashboardData(@RequestBody JSONObject storCode) {
|
||||
|
||||
JSONObject data = bigScreenService.getDashboardData("FJ");
|
||||
|
||||
return new ResponseEntity<>(data, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/getReportData")
|
||||
@Log("获取报表数据")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> getReportData() {
|
||||
try {
|
||||
JSONObject result = bigScreenService.getReportData();
|
||||
return new ResponseEntity<>(result, HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
log.error("获取报表数据失败", e);
|
||||
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/getWeeklyData")
|
||||
@Log("获取按周对比数据")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> getWeeklyData() {
|
||||
try {
|
||||
JSONObject result = bigScreenService.getWeeklyData();
|
||||
return new ResponseEntity<>(result, HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
log.error("获取按周对比数据失败", e);
|
||||
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,4 +21,19 @@ public interface BigScreenService {
|
||||
* @return PdaResponse
|
||||
*/
|
||||
List<JSONObject> getData(List<String> stors);
|
||||
|
||||
|
||||
JSONObject getDashboardData(String storCode);
|
||||
|
||||
/**
|
||||
* 获取报表数据
|
||||
* @return 报表数据JSON对象,包含统计数据和历史数据
|
||||
*/
|
||||
JSONObject getReportData();
|
||||
|
||||
/**
|
||||
* 获取按周对比数据
|
||||
* @return 按周对比数据JSON对象
|
||||
*/
|
||||
JSONObject getWeeklyData();
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import org.nl.wms.basedata_manage.service.IStructattrService;
|
||||
import org.nl.wms.basedata_manage.service.dao.Structattr;
|
||||
import org.nl.wms.basedata_manage.service.dao.mapper.BsrealStorattrMapper;
|
||||
import org.nl.wms.basedata_manage.service.dao.mapper.StructattrMapper;
|
||||
import org.nl.wms.bigscreen_manage.service.BigScreenService;
|
||||
import org.nl.wms.bigscreen_manage.service.dto.IvtAnalyse;
|
||||
import org.nl.wms.sch_manage.enums.TaskStatus;
|
||||
@@ -28,6 +29,7 @@ import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -57,6 +59,9 @@ public class BigScreenServiceImpl implements BigScreenService {
|
||||
@Autowired
|
||||
private ISchBaseTaskService iSchBaseTaskService;
|
||||
|
||||
@Autowired
|
||||
private StructattrMapper structattrMapper;
|
||||
|
||||
@Override
|
||||
public List<JSONObject> getData(List<String> stors) {
|
||||
// String storCode = "FJ";
|
||||
@@ -82,6 +87,16 @@ public class BigScreenServiceImpl implements BigScreenService {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject getDashboardData(String storCode) {
|
||||
JSONObject item = new JSONObject();
|
||||
//1.【库位总数】数据
|
||||
item.put("overview", overview(storCode));
|
||||
item.put("locations", locations(storCode));
|
||||
return item;
|
||||
}
|
||||
|
||||
/**
|
||||
//
|
||||
// * 货位使用
|
||||
@@ -93,6 +108,14 @@ public class BigScreenServiceImpl implements BigScreenService {
|
||||
// * use_percentage: 百分比(使用货位百分比)
|
||||
// * }
|
||||
// */
|
||||
private JSONObject overview(String storCode) {
|
||||
return structattrMapper.overview(storCode);
|
||||
}
|
||||
|
||||
private List<JSONObject> locations(String storCode) {
|
||||
return structattrMapper.locations(storCode);
|
||||
}
|
||||
|
||||
private JSONObject pointUse(String storCode) {
|
||||
// 返回数据
|
||||
JSONObject result = new JSONObject();
|
||||
@@ -123,6 +146,7 @@ public class BigScreenServiceImpl implements BigScreenService {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 实时库存分析
|
||||
*
|
||||
@@ -362,4 +386,337 @@ public class BigScreenServiceImpl implements BigScreenService {
|
||||
});
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject getReportData() {
|
||||
String storCode = "FJ"; // 默认为富佳仓库
|
||||
JSONObject result = new JSONObject();
|
||||
|
||||
// 1. 构建统计数据
|
||||
JSONObject stats = new JSONObject();
|
||||
|
||||
// 总任务数
|
||||
QueryWrapper<SchBaseTask> taskWrapper = new QueryWrapper<>();
|
||||
taskWrapper.lambda()
|
||||
.eq(SchBaseTask::getIs_delete, IOSConstant.IS_DELETE_NO)
|
||||
.eq(SchBaseTask::getTask_status,TaskStatus.FINISHED.getCode())
|
||||
;
|
||||
stats.put("totalTasks", iSchBaseTaskService.count(taskWrapper));
|
||||
|
||||
// 今日任务数
|
||||
QueryWrapper<SchBaseTask> todayTaskWrapper = new QueryWrapper<>();
|
||||
todayTaskWrapper.lambda()
|
||||
.eq(SchBaseTask::getIs_delete, IOSConstant.IS_DELETE_NO)
|
||||
.eq(SchBaseTask::getTask_status,TaskStatus.FINISHED.getCode())
|
||||
.ge(SchBaseTask::getCreate_time, DateUtil.beginOfDay(DateUtil.date()))
|
||||
.le(SchBaseTask::getCreate_time, DateUtil.endOfDay(DateUtil.date()));
|
||||
int todayTasks = iSchBaseTaskService.count(todayTaskWrapper);
|
||||
stats.put("todayTasks", todayTasks);
|
||||
|
||||
// 昨日任务数(计算日环比)
|
||||
QueryWrapper<SchBaseTask> yesterdayTaskWrapper = new QueryWrapper<>();
|
||||
yesterdayTaskWrapper.lambda()
|
||||
.eq(SchBaseTask::getIs_delete, IOSConstant.IS_DELETE_NO)
|
||||
.eq(SchBaseTask::getTask_status,TaskStatus.FINISHED.getCode())
|
||||
.ge(SchBaseTask::getCreate_time, DateUtil.beginOfDay(DateUtil.offsetDay(DateUtil.date(), -1)))
|
||||
.le(SchBaseTask::getCreate_time, DateUtil.endOfDay(DateUtil.offsetDay(DateUtil.date(), -1)));
|
||||
int yesterdayTasks = iSchBaseTaskService.count(yesterdayTaskWrapper);
|
||||
double dayOnDay = yesterdayTasks > 0 ? ((double)(todayTasks - yesterdayTasks) / yesterdayTasks) * 100 : 0;
|
||||
stats.put("dayOnDay", NumberUtil.round(dayOnDay, 1));
|
||||
|
||||
// 本月任务数
|
||||
QueryWrapper<SchBaseTask> monthTaskWrapper = new QueryWrapper<>();
|
||||
monthTaskWrapper.lambda()
|
||||
.eq(SchBaseTask::getIs_delete, IOSConstant.IS_DELETE_NO)
|
||||
.eq(SchBaseTask::getTask_status,TaskStatus.FINISHED.getCode())
|
||||
.ge(SchBaseTask::getCreate_time, DateUtil.beginOfMonth(DateUtil.date()))
|
||||
.le(SchBaseTask::getCreate_time, DateUtil.endOfMonth(DateUtil.date()));
|
||||
stats.put("monthTasks", iSchBaseTaskService.count(monthTaskWrapper));
|
||||
|
||||
// 月均任务数(简单计算:总任务数/12)
|
||||
// int totalTasks = iSchBaseTaskService.count(taskWrapper);
|
||||
// stats.put("monthlyAvg", Math.round((double)totalTasks / 12));
|
||||
|
||||
// 库位数量
|
||||
QueryWrapper<Structattr> structattrWrapper = new QueryWrapper<>();
|
||||
structattrWrapper.lambda().eq(Structattr::getStor_code, storCode)
|
||||
.eq(Structattr::getIs_used, Boolean.TRUE);
|
||||
stats.put("locationCount", iStructattrService.count(structattrWrapper));
|
||||
|
||||
// 在库数量
|
||||
int inventoryCount = iStructattrService.count(
|
||||
new QueryWrapper<Structattr>().lambda()
|
||||
.eq(Structattr::getStor_code, storCode)
|
||||
.eq(Structattr::getIs_used, Boolean.TRUE)
|
||||
.isNotNull(Structattr::getStoragevehicle_code));
|
||||
stats.put("inventoryCount", inventoryCount);
|
||||
|
||||
// 入库数量
|
||||
int inboundCount = iSchBaseTaskService.count(
|
||||
new QueryWrapper<SchBaseTask>().lambda()
|
||||
.eq(SchBaseTask::getConfig_code,"STInTask")
|
||||
.eq(SchBaseTask::getIs_delete, Boolean.FALSE)
|
||||
.eq(SchBaseTask::getTask_status,TaskStatus.FINISHED.getCode()));
|
||||
stats.put("inboundCount", inboundCount);
|
||||
// 出库数量
|
||||
int outboundCount = iSchBaseTaskService.count(
|
||||
new QueryWrapper<SchBaseTask>().lambda()
|
||||
.eq(SchBaseTask::getConfig_code,"STOutTask")
|
||||
.eq(SchBaseTask::getIs_delete, Boolean.FALSE)
|
||||
.eq(SchBaseTask::getTask_status,TaskStatus.FINISHED.getCode()));
|
||||
stats.put("outboundCount", outboundCount);
|
||||
// 运转数量
|
||||
int operationCount = iSchBaseTaskService.count(
|
||||
new QueryWrapper<SchBaseTask>().lambda()
|
||||
.eq(SchBaseTask::getConfig_code,"MoveTask")
|
||||
.eq(SchBaseTask::getIs_delete, Boolean.FALSE)
|
||||
.eq(SchBaseTask::getTask_status,TaskStatus.FINISHED.getCode()));
|
||||
stats.put("operationCount", operationCount);
|
||||
|
||||
result.put("stats", stats);
|
||||
|
||||
// 2. 构建历史数据(最近7天)
|
||||
List<JSONObject> historyList = new ArrayList<>();
|
||||
DateTime dateTime = DateUtil.offsetDay(DateUtil.date(), -6);
|
||||
List<String> dateList = DateUtil.rangeToList(dateTime, DateUtil.date(), DateField.DAY_OF_YEAR).stream()
|
||||
.map(DateTime::toString)
|
||||
.map(row -> row.substring(0, 10))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
for (String date : dateList) {
|
||||
JSONObject item = new JSONObject();
|
||||
item.put("date", date);
|
||||
|
||||
// 查询该日入库任务数
|
||||
QueryWrapper<SchBaseTask> inWrapper = new QueryWrapper<>();
|
||||
inWrapper.lambda()
|
||||
.eq(SchBaseTask::getIs_delete, IOSConstant.IS_DELETE_NO)
|
||||
.eq(SchBaseTask::getConfig_code, "STInTask")
|
||||
.ge(SchBaseTask::getCreate_time, DateUtil.parse(date + " 00:00:00"))
|
||||
.le(SchBaseTask::getCreate_time, DateUtil.parse(date + " 23:59:59"));
|
||||
item.put("inbound", iSchBaseTaskService.count(inWrapper));
|
||||
|
||||
// 查询该日出库任务数
|
||||
QueryWrapper<SchBaseTask> outWrapper = new QueryWrapper<>();
|
||||
outWrapper.lambda()
|
||||
.eq(SchBaseTask::getIs_delete, IOSConstant.IS_DELETE_NO)
|
||||
.eq(SchBaseTask::getConfig_code, "STOutTask")
|
||||
.ge(SchBaseTask::getCreate_time, DateUtil.parse(date + " 00:00:00"))
|
||||
.le(SchBaseTask::getCreate_time, DateUtil.parse(date + " 23:59:59"));
|
||||
item.put("outbound", iSchBaseTaskService.count(outWrapper));
|
||||
|
||||
// 其他搬运任务数
|
||||
QueryWrapper<SchBaseTask> otherWrapper = new QueryWrapper<>();
|
||||
otherWrapper.lambda()
|
||||
.eq(SchBaseTask::getIs_delete, IOSConstant.IS_DELETE_NO)
|
||||
.ne(SchBaseTask::getConfig_code, "STOutTask")
|
||||
.ne(SchBaseTask::getConfig_code, "STInTask")
|
||||
.ge(SchBaseTask::getCreate_time, DateUtil.parse(date + " 00:00:00"))
|
||||
.le(SchBaseTask::getCreate_time, DateUtil.parse(date + " 23:59:59"));
|
||||
item.put("other", iSchBaseTaskService.count(otherWrapper));
|
||||
|
||||
// 计算总数
|
||||
int inbound = iSchBaseTaskService.count(inWrapper);
|
||||
int outbound = iSchBaseTaskService.count(outWrapper);
|
||||
int other = iSchBaseTaskService.count(otherWrapper);
|
||||
item.put("total", inbound + outbound + other);
|
||||
|
||||
historyList.add(item);
|
||||
}
|
||||
|
||||
result.put("historyList", historyList);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject getWeeklyData() {
|
||||
String storCode = "FJ"; // 默认为富佳仓库
|
||||
JSONObject result = new JSONObject();
|
||||
JSONObject data = new JSONObject(); // 创建data对象用于封装所有数据
|
||||
|
||||
// 获取当前时间和近3周的时间范围
|
||||
DateTime now = DateUtil.date();
|
||||
|
||||
// 1. 计算周对比数据(本周和上周)
|
||||
// 本周数据
|
||||
DateTime weekStart = DateUtil.beginOfWeek(now, true); // 周一为起始
|
||||
DateTime weekEnd = DateUtil.endOfWeek(now, true);
|
||||
|
||||
// 上周数据
|
||||
DateTime lastWeekStart = DateUtil.beginOfWeek(DateUtil.offsetWeek(now, -1), true);
|
||||
DateTime lastWeekEnd = DateUtil.endOfWeek(DateUtil.offsetWeek(now, -1), true);
|
||||
|
||||
// 本周任务统计
|
||||
JSONObject currentWeek = new JSONObject();
|
||||
QueryWrapper<SchBaseTask> currentWeekWrapper = new QueryWrapper<>();
|
||||
currentWeekWrapper.lambda()
|
||||
.eq(SchBaseTask::getIs_delete, IOSConstant.IS_DELETE_NO)
|
||||
.ge(SchBaseTask::getCreate_time, weekStart)
|
||||
.le(SchBaseTask::getCreate_time, weekEnd);
|
||||
Integer totalTasks = iSchBaseTaskService.count(currentWeekWrapper);
|
||||
currentWeek.put("totalTasks", totalTasks);
|
||||
|
||||
// 本周已完成任务数
|
||||
QueryWrapper<SchBaseTask> currentWeekCompletedWrapper = new QueryWrapper<>();
|
||||
currentWeekCompletedWrapper.lambda()
|
||||
.eq(SchBaseTask::getIs_delete, IOSConstant.IS_DELETE_NO)
|
||||
.eq(SchBaseTask::getTask_status, TaskStatus.FINISHED.getCode())
|
||||
.ge(SchBaseTask::getCreate_time, weekStart)
|
||||
.le(SchBaseTask::getCreate_time, weekEnd);
|
||||
Integer completedTasks = iSchBaseTaskService.count(currentWeekCompletedWrapper);
|
||||
currentWeek.put("completedTasks", completedTasks);
|
||||
|
||||
// 计算完成率
|
||||
double completionRate = totalTasks > 0 ? (double) completedTasks / totalTasks * 100 : 0;
|
||||
currentWeek.put("completionRate", NumberUtil.round(completionRate, 1));
|
||||
|
||||
// 本周入库任务数
|
||||
QueryWrapper<SchBaseTask> currentWeekInWrapper = new QueryWrapper<>();
|
||||
currentWeekInWrapper.lambda()
|
||||
.eq(SchBaseTask::getIs_delete, IOSConstant.IS_DELETE_NO)
|
||||
.eq(SchBaseTask::getConfig_code, "STInTask")
|
||||
.ge(SchBaseTask::getCreate_time, weekStart)
|
||||
.le(SchBaseTask::getCreate_time, weekEnd);
|
||||
currentWeek.put("inboundTasks", iSchBaseTaskService.count(currentWeekInWrapper));
|
||||
|
||||
// 本周出库任务数
|
||||
QueryWrapper<SchBaseTask> currentWeekOutWrapper = new QueryWrapper<>();
|
||||
currentWeekOutWrapper.lambda()
|
||||
.eq(SchBaseTask::getIs_delete, IOSConstant.IS_DELETE_NO)
|
||||
.eq(SchBaseTask::getConfig_code, "STOutTask")
|
||||
.ge(SchBaseTask::getCreate_time, weekStart)
|
||||
.le(SchBaseTask::getCreate_time, weekEnd);
|
||||
currentWeek.put("outboundTasks", iSchBaseTaskService.count(currentWeekOutWrapper));
|
||||
|
||||
// 上周任务统计
|
||||
JSONObject lastWeek = new JSONObject();
|
||||
QueryWrapper<SchBaseTask> lastWeekWrapper = new QueryWrapper<>();
|
||||
lastWeekWrapper.lambda()
|
||||
.eq(SchBaseTask::getIs_delete, IOSConstant.IS_DELETE_NO)
|
||||
.ge(SchBaseTask::getCreate_time, lastWeekStart)
|
||||
.le(SchBaseTask::getCreate_time, lastWeekEnd);
|
||||
Integer lastTotalTasks = iSchBaseTaskService.count(lastWeekWrapper);
|
||||
lastWeek.put("totalTasks", lastTotalTasks);
|
||||
|
||||
// 上周已完成任务数
|
||||
QueryWrapper<SchBaseTask> lastWeekCompletedWrapper = new QueryWrapper<>();
|
||||
lastWeekCompletedWrapper.lambda()
|
||||
.eq(SchBaseTask::getIs_delete, IOSConstant.IS_DELETE_NO)
|
||||
.eq(SchBaseTask::getTask_status, TaskStatus.FINISHED.getCode())
|
||||
.ge(SchBaseTask::getCreate_time, lastWeekStart)
|
||||
.le(SchBaseTask::getCreate_time, lastWeekEnd);
|
||||
Integer lastCompletedTasks = iSchBaseTaskService.count(lastWeekCompletedWrapper);
|
||||
lastWeek.put("completedTasks", lastCompletedTasks);
|
||||
|
||||
// 计算上周完成率
|
||||
double lastCompletionRate = lastTotalTasks > 0 ? (double) lastCompletedTasks / lastTotalTasks * 100 : 0;
|
||||
lastWeek.put("completionRate", NumberUtil.round(lastCompletionRate, 1));
|
||||
|
||||
// 上周入库任务数
|
||||
QueryWrapper<SchBaseTask> lastWeekInWrapper = new QueryWrapper<>();
|
||||
lastWeekInWrapper.lambda()
|
||||
.eq(SchBaseTask::getIs_delete, IOSConstant.IS_DELETE_NO)
|
||||
.eq(SchBaseTask::getConfig_code, "STInTask")
|
||||
.ge(SchBaseTask::getCreate_time, lastWeekStart)
|
||||
.le(SchBaseTask::getCreate_time, lastWeekEnd);
|
||||
lastWeek.put("inboundTasks", iSchBaseTaskService.count(lastWeekInWrapper));
|
||||
|
||||
// 上周出库任务数
|
||||
QueryWrapper<SchBaseTask> lastWeekOutWrapper = new QueryWrapper<>();
|
||||
lastWeekOutWrapper.lambda()
|
||||
.eq(SchBaseTask::getIs_delete, IOSConstant.IS_DELETE_NO)
|
||||
.eq(SchBaseTask::getConfig_code, "STOutTask")
|
||||
.ge(SchBaseTask::getCreate_time, lastWeekStart)
|
||||
.le(SchBaseTask::getCreate_time, lastWeekEnd);
|
||||
lastWeek.put("outboundTasks", iSchBaseTaskService.count(lastWeekOutWrapper));
|
||||
|
||||
// 计算周环比
|
||||
double totalGrowthRate = lastTotalTasks > 0
|
||||
? ((double)(totalTasks - lastTotalTasks) / lastTotalTasks) * 100 : 0;
|
||||
|
||||
double inboundGrowthRate = lastWeek.getInteger("inboundTasks") > 0
|
||||
? ((double)(currentWeek.getInteger("inboundTasks") - lastWeek.getInteger("inboundTasks"))
|
||||
/ lastWeek.getInteger("inboundTasks")) * 100 : 0;
|
||||
|
||||
double outboundGrowthRate = lastWeek.getInteger("outboundTasks") > 0
|
||||
? ((double)(currentWeek.getInteger("outboundTasks") - lastWeek.getInteger("outboundTasks"))
|
||||
/ lastWeek.getInteger("outboundTasks")) * 100 : 0;
|
||||
|
||||
JSONObject growthRates = new JSONObject();
|
||||
growthRates.put("totalGrowthRate", NumberUtil.round(totalGrowthRate, 1));
|
||||
growthRates.put("inboundGrowthRate", NumberUtil.round(inboundGrowthRate, 1));
|
||||
growthRates.put("outboundGrowthRate", NumberUtil.round(outboundGrowthRate, 1));
|
||||
growthRates.put("growthRate", NumberUtil.round(totalGrowthRate, 1)); // 为了兼容前端dashboard2.js中的直接使用
|
||||
|
||||
// 2. 计算近3周的数据(用于图表)
|
||||
List<String> weeks = new ArrayList<>();
|
||||
List<Integer> inboundData = new ArrayList<>();
|
||||
List<Integer> outboundData = new ArrayList<>();
|
||||
List<Integer> otherData = new ArrayList<>();
|
||||
|
||||
// 获取近3周的数据
|
||||
for (int i = 2; i >= 0; i--) {
|
||||
DateTime targetWeekStart = DateUtil.beginOfWeek(DateUtil.offsetWeek(now, -i), true);
|
||||
DateTime targetWeekEnd = DateUtil.endOfWeek(DateUtil.offsetWeek(now, -i), true);
|
||||
|
||||
// 格式化周标签(MM-DD-MM-DD格式)
|
||||
String weekLabel = targetWeekStart.toString("MM-dd") + "-" + targetWeekEnd.toString("MM-dd");
|
||||
weeks.add(weekLabel);
|
||||
|
||||
// 该周入库任务数
|
||||
QueryWrapper<SchBaseTask> weekInWrapper = new QueryWrapper<>();
|
||||
weekInWrapper.lambda()
|
||||
.eq(SchBaseTask::getIs_delete, IOSConstant.IS_DELETE_NO)
|
||||
.eq(SchBaseTask::getConfig_code, "STInTask")
|
||||
.ge(SchBaseTask::getCreate_time, targetWeekStart)
|
||||
.le(SchBaseTask::getCreate_time, targetWeekEnd);
|
||||
inboundData.add(iSchBaseTaskService.count(weekInWrapper));
|
||||
|
||||
// 该周出库任务数
|
||||
QueryWrapper<SchBaseTask> weekOutWrapper = new QueryWrapper<>();
|
||||
weekOutWrapper.lambda()
|
||||
.eq(SchBaseTask::getIs_delete, IOSConstant.IS_DELETE_NO)
|
||||
.eq(SchBaseTask::getConfig_code, "STOutTask")
|
||||
.ge(SchBaseTask::getCreate_time, targetWeekStart)
|
||||
.le(SchBaseTask::getCreate_time, targetWeekEnd);
|
||||
outboundData.add(iSchBaseTaskService.count(weekOutWrapper));
|
||||
|
||||
// 该周其他任务数(非入库出库任务)
|
||||
QueryWrapper<SchBaseTask> weekOtherWrapper = new QueryWrapper<>();
|
||||
weekOtherWrapper.lambda()
|
||||
.eq(SchBaseTask::getIs_delete, IOSConstant.IS_DELETE_NO)
|
||||
.notIn(SchBaseTask::getConfig_code, Arrays.asList("STInTask", "STOutTask"))
|
||||
.ge(SchBaseTask::getCreate_time, targetWeekStart)
|
||||
.le(SchBaseTask::getCreate_time, targetWeekEnd);
|
||||
otherData.add(iSchBaseTaskService.count(weekOtherWrapper));
|
||||
}
|
||||
|
||||
// 构造符合前端要求的响应结构
|
||||
JSONObject chartData = new JSONObject();
|
||||
chartData.put("weeks", weeks);
|
||||
chartData.put("inboundData", inboundData);
|
||||
chartData.put("outboundData", outboundData);
|
||||
chartData.put("otherData", otherData);
|
||||
|
||||
// 将所有数据放入data对象
|
||||
data.put("thisWeek", currentWeek);
|
||||
data.put("lastWeek", lastWeek);
|
||||
data.put("growthRate", NumberUtil.round(totalGrowthRate, 1)); // 为了兼容前端dashboard2.js中的直接使用
|
||||
data.put("growthRates", growthRates);
|
||||
data.put("currentWeekDate", weekStart.toString("yyyy-MM-dd") + " 至 " + weekEnd.toString("yyyy-MM-dd"));
|
||||
data.put("lastWeekDate", lastWeekStart.toString("yyyy-MM-dd") + " 至 " + lastWeekEnd.toString("yyyy-MM-dd"));
|
||||
data.put("weeks", weeks);
|
||||
data.put("inboundData", inboundData);
|
||||
data.put("outboundData", outboundData);
|
||||
data.put("otherData", otherData);
|
||||
|
||||
// 为了兼容两种前端使用方式,将数据同时放在根级别和data对象中
|
||||
result.put("success", true);
|
||||
result.put("data", data);
|
||||
result.put("thisWeek", currentWeek);
|
||||
result.put("lastWeek", lastWeek);
|
||||
result.put("growthRate", NumberUtil.round(totalGrowthRate, 1));
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -305,9 +305,9 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
||||
}
|
||||
// 校验终点
|
||||
Structattr end_point = end_point_code_list.get(0);
|
||||
start_point.setLock_type(IOSEnum.LOCK_TYPE.code("其他锁"));
|
||||
start_point.setLock_type(IOSEnum.LOCK_TYPE.code("入库锁"));
|
||||
iStructattrService.updateById(start_point);
|
||||
end_point.setLock_type(IOSEnum.LOCK_TYPE.code("其他锁"));
|
||||
end_point.setLock_type(IOSEnum.LOCK_TYPE.code("入库锁"));
|
||||
iStructattrService.updateById(end_point);
|
||||
// 创建任务
|
||||
JSONObject task = new JSONObject();
|
||||
|
||||
@@ -4,8 +4,10 @@ import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.http.HttpStatus;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.language.LangBehavior;
|
||||
@@ -13,6 +15,8 @@ import org.nl.wms.basedata_manage.service.IStructattrService;
|
||||
import org.nl.wms.basedata_manage.service.dao.Structattr;
|
||||
import org.nl.wms.basedata_manage.service.dao.mapper.StructattrMapper;
|
||||
import org.nl.wms.pda_manage.sch_manage.service.PdaSchPointService;
|
||||
import org.nl.wms.warehouse_manage.service.IMdPbGroupplateService;
|
||||
import org.nl.wms.warehouse_manage.service.dao.GroupPlate;
|
||||
import org.nl.wms.warehouse_manage.service.dao.mapper.StIvtMoveinvdtlMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -29,6 +33,7 @@ import java.util.List;
|
||||
* @since 2025-06-06
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class PdaSchPointServiceImpl implements PdaSchPointService {
|
||||
@Resource
|
||||
private StIvtMoveinvdtlMapper stIvtMoveinvdtlMapper;
|
||||
@@ -36,6 +41,8 @@ public class PdaSchPointServiceImpl implements PdaSchPointService {
|
||||
private IStructattrService iStructattrService;
|
||||
@Resource
|
||||
private StructattrMapper structattrMapper;
|
||||
@Resource
|
||||
private IMdPbGroupplateService iMdPbGroupplateService;
|
||||
|
||||
@Override
|
||||
public JSONObject getPoint(JSONObject whereJson) {
|
||||
@@ -109,6 +116,7 @@ public class PdaSchPointServiceImpl implements PdaSchPointService {
|
||||
}
|
||||
// 载具号
|
||||
String struct_code = whereJson.getString("struct_code");
|
||||
log.info("点位清理,载具号=【{}】,库位号=【{}】", vehicle_code, struct_code);
|
||||
if (ObjectUtil.isEmpty(struct_code)) {
|
||||
throw new BadRequestException(LangBehavior.language("pda_manage.point_code_empty"));
|
||||
}
|
||||
@@ -127,6 +135,13 @@ public class PdaSchPointServiceImpl implements PdaSchPointService {
|
||||
.eq(Structattr::getStruct_code, whereJson.getString("struct_code"))
|
||||
.set(Structattr::getStoragevehicle_code, null)
|
||||
);
|
||||
|
||||
//删除组盘
|
||||
iMdPbGroupplateService.remove(
|
||||
new QueryWrapper<GroupPlate>()
|
||||
.eq("storagevehicle_code", struct.getStoragevehicle_code())
|
||||
);
|
||||
|
||||
JSONObject ret = new JSONObject();
|
||||
ret.put("status", String.valueOf(HttpStatus.HTTP_OK));
|
||||
ret.put("message","操作成功");
|
||||
|
||||
@@ -897,7 +897,7 @@ var config = {
|
||||
"allocated_by": "分配人",
|
||||
"allocated_time": "分配时间",
|
||||
"confirmed_by": "确认人",
|
||||
"confirmed_time": "确认时间",
|
||||
"confirmed_time": "入库时间",
|
||||
"select_bill": "请选择一条单据",
|
||||
"bill_confirm_success": "单据确认成功!",
|
||||
"system_generated": "系统生成",
|
||||
@@ -928,6 +928,10 @@ var config = {
|
||||
"task_code": "任务号"
|
||||
},
|
||||
"outbill": {
|
||||
"order_quantity":"订单数量",
|
||||
"material_list_selection":"用料清单选择",
|
||||
"material_list_blur_query":"用料清单物料",
|
||||
"material":"物料编码",
|
||||
"outbound_weight":"出库重量",
|
||||
"edit_out_bill":"出库单编辑",
|
||||
"out_detail":"出库明细",
|
||||
@@ -989,7 +993,7 @@ var config = {
|
||||
"allocated_by": "分配人",
|
||||
"allocated_time": "分配时间",
|
||||
"confirmed_by": "确认人",
|
||||
"confirmed_time": "确认时间",
|
||||
"confirmed_time": "出库时间",
|
||||
"select_bill": "请选择一条单据",
|
||||
"bill_confirm_success": "单据确认成功!",
|
||||
"system_generated": "系统生成",
|
||||
@@ -1079,6 +1083,9 @@ var config = {
|
||||
"operation": "操作"
|
||||
},
|
||||
"common": {
|
||||
"date":"日期",
|
||||
"cancel":"取消",
|
||||
"confirm":"确定",
|
||||
"Close":"关闭",
|
||||
"material_code":"物料编码",
|
||||
"material_name":"物料名称",
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.nl.wms.basedata_manage.service.dao.mapper.StructattrMapper">
|
||||
|
||||
<!-- 获取报表统计数据 -->
|
||||
<select id="getReportData" resultType="com.alibaba.fastjson.JSONObject">
|
||||
SELECT
|
||||
COUNT(DISTINCT task_id) AS taskCount,
|
||||
SUM(CASE WHEN task_status = '4' THEN 1 ELSE 0 END) AS completedTaskCount,
|
||||
COUNT(DISTINCT struct_id) AS locationCount,
|
||||
SUM(CASE WHEN is_used = '1' AND storagevehicle_code IS NOT NULL THEN 1 ELSE 0 END) AS usedLocationCount
|
||||
FROM
|
||||
sch_base_task t
|
||||
LEFT JOIN
|
||||
st_ivt_structattr s ON t.point_code1 = s.struct_code OR t.point_code2 = s.struct_code
|
||||
WHERE
|
||||
t.create_time >= DATE_SUB(NOW(), INTERVAL 7 DAY)
|
||||
</select>
|
||||
|
||||
<!-- 获取最近7天的历史数据 -->
|
||||
<select id="getHistoryData" resultType="com.alibaba.fastjson.JSONObject">
|
||||
SELECT
|
||||
DATE(create_time) AS date,
|
||||
COUNT(task_id) AS taskCount,
|
||||
SUM(CASE WHEN task_status = '4' THEN 1 ELSE 0 END) AS completedCount
|
||||
FROM
|
||||
sch_base_task
|
||||
WHERE
|
||||
create_time >= DATE_SUB(NOW(), INTERVAL 7 DAY)
|
||||
GROUP BY
|
||||
DATE(create_time)
|
||||
ORDER BY
|
||||
date ASC
|
||||
</select>
|
||||
|
||||
<!-- 获取本周任务数据 -->
|
||||
<select id="getThisWeekData" resultType="com.alibaba.fastjson.JSONObject">
|
||||
SELECT
|
||||
COUNT(task_id) AS totalTasks,
|
||||
SUM(CASE WHEN task_status = '4' THEN 1 ELSE 0 END) AS completedTasks,
|
||||
ROUND(SUM(CASE WHEN task_status = '4' THEN 1 ELSE 0 END) / COUNT(task_id) * 100, 2) AS completionRate
|
||||
FROM
|
||||
sch_base_task
|
||||
WHERE
|
||||
YEARWEEK(create_time, 1) = YEARWEEK(NOW(), 1)
|
||||
</select>
|
||||
|
||||
<!-- 获取上周任务数据 -->
|
||||
<select id="getLastWeekData" resultType="com.alibaba.fastjson.JSONObject">
|
||||
SELECT
|
||||
COUNT(task_id) AS totalTasks,
|
||||
SUM(CASE WHEN task_status = '4' THEN 1 ELSE 0 END) AS completedTasks,
|
||||
ROUND(SUM(CASE WHEN task_status = '4' THEN 1 ELSE 0 END) / COUNT(task_id) * 100, 2) AS completionRate
|
||||
FROM
|
||||
sch_base_task
|
||||
WHERE
|
||||
YEARWEEK(create_time, 1) = YEARWEEK(NOW(), 1) - 1
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user