fix:排版任务增加日期选择
This commit is contained in:
parent
555a6dd856
commit
8a6e79aef9
|
@ -7,6 +7,7 @@ import org.jeecg.common.Excel.ImportExcel;
|
|||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.config.valid.InsertGroup;
|
||||
import org.jeecg.config.valid.UpdateGroup;
|
||||
import org.jeecg.modules.system.entity.vo.SysTaskHandleVo;
|
||||
import org.jeecg.modules.system.entity.SysTaskSystem;
|
||||
import org.jeecg.modules.system.entity.vo.ImportViewVo;
|
||||
import org.jeecg.modules.system.entity.vo.SysTaskChangeVo;
|
||||
|
@ -58,8 +59,8 @@ public class SysTaskController {
|
|||
|
||||
@PutMapping("update")
|
||||
@ApiOperation(value = "修改排班任务", notes = "修改排班任务")
|
||||
public Result update(@RequestBody @Validated(value = UpdateGroup.class) List<SysTaskSystem> sysTasks){
|
||||
return sysTaskService.update(sysTasks);
|
||||
public Result update(@RequestBody @Validated(value = UpdateGroup.class)SysTaskHandleVo sysTaskHandleVo){
|
||||
return sysTaskService.update(sysTaskHandleVo);
|
||||
}
|
||||
|
||||
@DeleteMapping("deleteById")
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
package org.jeecg.modules.system.entity.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import org.jeecg.modules.system.entity.SysTaskSystem;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class SysTaskHandleVo {
|
||||
|
||||
private List<SysTaskSystem> sysTasks;
|
||||
|
||||
/**
|
||||
* 开始日期
|
||||
*/
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
private Date startTime;
|
||||
|
||||
/**
|
||||
* 结束日期
|
||||
*/
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
private Date endTime;
|
||||
|
||||
}
|
|
@ -3,10 +3,7 @@ package org.jeecg.modules.system.service;
|
|||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.modules.system.entity.SysTaskSystem;
|
||||
import org.jeecg.modules.system.entity.vo.ImportViewVo;
|
||||
import org.jeecg.modules.system.entity.vo.SysTaskChangeVo;
|
||||
import org.jeecg.modules.system.entity.vo.SysTaskExportVo;
|
||||
import org.jeecg.modules.system.entity.vo.SysTaskVo;
|
||||
import org.jeecg.modules.system.entity.vo.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
@ -44,6 +41,13 @@ public interface ISysTaskService extends IService<SysTaskSystem> {
|
|||
*/
|
||||
Result update(List<SysTaskSystem> sysTasks);
|
||||
|
||||
/**
|
||||
* 修改用户的任务信息
|
||||
* @param sysTaskHandleVo
|
||||
* @return
|
||||
*/
|
||||
Result update(SysTaskHandleVo sysTaskHandleVo);
|
||||
|
||||
/**
|
||||
* 删除排班任务信息
|
||||
* @param taskId
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package org.jeecg.modules.system.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
|
@ -247,6 +248,67 @@ public class SysTaskServiceImpl extends ServiceImpl<SysTaskMapper, SysTaskSystem
|
|||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public Result update(SysTaskHandleVo sysTaskHandleVo) {
|
||||
Result result = new Result();
|
||||
// 排版数据
|
||||
List<SysTaskSystem> sysTasks = sysTaskHandleVo.getSysTasks();
|
||||
if (Objects.isNull(sysTaskHandleVo.getStartTime()) || Objects.isNull(sysTaskHandleVo.getEndTime())){
|
||||
return result.error500("Please select a date!");
|
||||
}
|
||||
if (CollectionUtils.isEmpty(sysTasks)){
|
||||
return result.error500("Please select a station!");
|
||||
}
|
||||
|
||||
//获取request
|
||||
HttpServletRequest request = SpringContextUtils.getHttpServletRequest();
|
||||
//获取当前操作人用户名
|
||||
String username = JwtUtil.getUserNameByToken(request);
|
||||
//设置IP地址
|
||||
String ipAddr = IpUtils.getIpAddr(request);
|
||||
|
||||
List<SysTaskSystem> tasks = Lists.newArrayList();
|
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
Date currnetDate = sysTaskHandleVo.getStartTime();
|
||||
// 按照选择的日期区间每天插入排版数据
|
||||
while (!currnetDate.after(sysTaskHandleVo.getEndTime())) {
|
||||
System.out.println(sdf.format(currnetDate));
|
||||
// 清空当天排版任务
|
||||
this.deleteByDate(currnetDate);
|
||||
//遍历排班任务进行存储
|
||||
for (SysTaskSystem sysTask:sysTasks) {
|
||||
SysTaskSystem task = new SysTaskSystem();
|
||||
//操作人
|
||||
sysTask.setCreateBy(username);
|
||||
//操作人的ip
|
||||
sysTask.setOperateIp(ipAddr);
|
||||
//id
|
||||
sysTask.setId(String.valueOf(IdWorker.getId()));
|
||||
// 排班日期
|
||||
sysTask.setSchedulingDate(currnetDate);
|
||||
//创建时间
|
||||
sysTask.setCreateTime(new Date());
|
||||
BeanUtil.copyProperties(sysTask, task);
|
||||
tasks.add(task);
|
||||
//如果排班任务中台站信息不为空
|
||||
if (CollectionUtils.isNotEmpty(sysTask.getStationList())){
|
||||
sysTaskStationService.create(sysTask.getId(), ipAddr, sysTask.getStationList());
|
||||
}
|
||||
}
|
||||
// 更新日期
|
||||
currnetDate = new Date(currnetDate.getTime() + 24 * 60 * 60 * 1000);
|
||||
}
|
||||
if(CollectionUtils.isNotEmpty(tasks)){
|
||||
this.saveBatch(tasks);
|
||||
}
|
||||
result.setSuccess(true);
|
||||
result.success("Modified successfully");
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据排班任务日期删除历史任务信息
|
||||
* @param schedulingDate
|
||||
|
@ -257,6 +319,9 @@ public class SysTaskServiceImpl extends ServiceImpl<SysTaskMapper, SysTaskSystem
|
|||
LambdaQueryWrapper<SysTaskSystem> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(SysTaskSystem::getSchedulingDate, DateUtils.parseDate(DateUtils.formatDate(schedulingDate, "yyyy-MM-dd"), "yyyy-MM-dd"));
|
||||
List<SysTaskSystem> sysTasks = this.baseMapper.selectList(queryWrapper);
|
||||
if(CollectionUtils.isEmpty(sysTasks)){
|
||||
return;
|
||||
}
|
||||
//获取任务信息的id
|
||||
List<String> taskIds = sysTasks.stream().map(SysTaskSystem::getId).collect(Collectors.toList());
|
||||
//根据任务id删除关联的台站信息
|
||||
|
|
Loading…
Reference in New Issue
Block a user