feat:排班任务接口返回内容增加用户名称及台站名称

This commit is contained in:
qiaoqinzheng 2023-05-18 15:38:04 +08:00
parent aa01541a11
commit 0f9f907ddb
4 changed files with 23 additions and 6 deletions

View File

@ -48,6 +48,9 @@ public class SysTask implements Serializable {
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date updateTime; private Date updateTime;
@TableField(exist = false)
private String userName;
@TableField(exist = false) @TableField(exist = false)
private List<SysTaskStation> stationList; private List<SysTaskStation> stationList;

View File

@ -1,6 +1,7 @@
package org.jeecg.modules.system.entity.vo; package org.jeecg.modules.system.entity.vo;
import lombok.Data; import lombok.Data;
import org.jeecg.modules.system.entity.SysTaskStation;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date; import java.util.Date;
@ -20,5 +21,5 @@ public class SysTaskVo {
private Integer number; private Integer number;
private List<String> stationList; private List<SysTaskStation> stationList;
} }

View File

@ -7,11 +7,10 @@
t.user_id, t.user_id,
t.scheduling_date, t.scheduling_date,
t.id, t.id,
count(s.task_id) number, count(t.id) number,
u.username u.username
FROM FROM
sys_task t sys_task t
left join sys_task_station s on t.id = s.task_id
left join sys_user u on u.id = t.user_id left join sys_user u on u.id = t.user_id
where t.scheduling_date BETWEEN #{firstDay} and #{lastDay} where t.scheduling_date BETWEEN #{firstDay} and #{lastDay}
group by t.user_id,t.scheduling_date,t.id,u.username group by t.user_id,t.scheduling_date,t.id,u.username
@ -21,10 +20,11 @@
SELECT SELECT
t.user_id as userId, t.user_id as userId,
t.scheduling_date as schedulingDate, t.scheduling_date as schedulingDate,
t.id t.id,
u.username as userName
FROM FROM
sys_task t sys_task t
left join sys_task_station s on t.id = s.task_id left join sys_user u on u.id = t.user_id
where t.scheduling_date BETWEEN #{firstDay} and #{lastDay} where t.scheduling_date BETWEEN #{firstDay} and #{lastDay}
</select> </select>

View File

@ -90,7 +90,7 @@ public class SysTaskServiceImpl extends ServiceImpl<SysTaskMapper, SysTask> impl
//遍历排版任务信息 //遍历排版任务信息
for (SysTaskVo taskVo:sysTaskVos) { for (SysTaskVo taskVo:sysTaskVos) {
//根据排版任务id过滤出属于当前任务的台站集合取台站名称字段合成集合 //根据排版任务id过滤出属于当前任务的台站集合取台站名称字段合成集合
List<String> stationNames = sysTaskStations.stream().filter(item -> item.getTaskId().equals(taskVo.getId())).map(SysTaskStation::getStationName).collect(Collectors.toList()); List<SysTaskStation> stationNames = sysTaskStations.stream().filter(item -> item.getTaskId().equals(taskVo.getId())).collect(Collectors.toList());
//返回台站名称集合 //返回台站名称集合
taskVo.setStationList(stationNames); taskVo.setStationList(stationNames);
} }
@ -118,6 +118,8 @@ public class SysTaskServiceImpl extends ServiceImpl<SysTaskMapper, SysTask> impl
@Override @Override
public Result<List<SysTask>> findInfo(Date day) { public Result<List<SysTask>> findInfo(Date day) {
Result<List<SysTask>> result = new Result(); Result<List<SysTask>> result = new Result();
//获取全部台站信息
List<GardsStations> gardsStations = gardsStationsService.getGardsStations();
try { try {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar cal = Calendar.getInstance(); Calendar cal = Calendar.getInstance();
@ -131,6 +133,17 @@ public class SysTaskServiceImpl extends ServiceImpl<SysTaskMapper, SysTask> impl
queryWrapper.select(SysTaskStation::getId,SysTaskStation::getTaskId,SysTaskStation::getStationId); queryWrapper.select(SysTaskStation::getId,SysTaskStation::getTaskId,SysTaskStation::getStationId);
List<SysTaskStation> taskStations = sysTaskStationMapper.selectList(queryWrapper); List<SysTaskStation> taskStations = sysTaskStationMapper.selectList(queryWrapper);
if (CollectionUtils.isNotEmpty(taskStations)){ if (CollectionUtils.isNotEmpty(taskStations)){
//遍历所有台站信息并赋值台站名称
for (SysTaskStation taskStation:taskStations) {
//通过stream流获取当前台站id对应的台站信息
List<GardsStations> gardsStationsList = gardsStations.stream().filter(item -> item.getStationId().toString().equals(taskStation.getStationId())).collect(Collectors.toList());
//如果台站数量大于0则说明有对应的台站信息
if (CollectionUtils.isNotEmpty(gardsStationsList)){
//台站id唯一取第一条数据
GardsStations stations = gardsStationsList.get(0);
taskStation.setStationName(stations.getStationCode());
}
}
for (SysTask sysTask:sysTasks) { for (SysTask sysTask:sysTasks) {
List<SysTaskStation> stations = taskStations.stream().filter(item -> item.getTaskId().equals(sysTask.getId())).collect(Collectors.toList()); List<SysTaskStation> stations = taskStations.stream().filter(item -> item.getTaskId().equals(sysTask.getId())).collect(Collectors.toList());
sysTask.setStationList(stations); sysTask.setStationList(stations);