feature : task history

pull/6221/head
Gauthier LO 2023-08-22 15:06:37 +02:00
parent ef0ff44d23
commit 06d405b7e0
17 changed files with 470 additions and 168 deletions

View File

@ -12,8 +12,8 @@ import javax.servlet.http.HttpServletResponse;
import org.jeecg.common.api.vo.Result; import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.query.QueryGenerator; import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.util.oConvertUtils; import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.business.entity.PendingTask; import org.jeecg.modules.business.entity.Task;
import org.jeecg.modules.business.service.IPendingTaskService; import org.jeecg.modules.business.service.ITaskService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
@ -38,123 +38,128 @@ import org.jeecg.common.aspect.annotation.AutoLog;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
/** /**
* @Description: to know if a task in launched * @Description: tasks
* @Author: jeecg-boot * @Author: jeecg-boot
* @Date: 2023-08-17 * @Date: 2023-08-22
* @Version: V1.0 * @Version: V1.0
*/ */
@Api(tags="pendingTask") @Api(tags="tasks")
@RestController @RestController
@RequestMapping("/pendingTask") @RequestMapping("/business/task")
@Slf4j @Slf4j
public class PendingTaskController extends JeecgController<PendingTask, IPendingTaskService> { public class TaskController extends JeecgController<Task, ITaskService> {
@Autowired @Autowired
private IPendingTaskService pendingTaskService; private ITaskService taskService;
/** /**
* *
* *
* @param pendingTask * @param task
* @param pageNo * @param pageNo
* @param pageSize * @param pageSize
* @param req * @param req
* @return * @return
*/ */
//@AutoLog(value = "to know if a task in launched-分页列表查询") //@AutoLog(value = "tasks-分页列表查询")
@ApiOperation(value="to know if a task in launched-分页列表查询", notes="to know if a task in launched-分页列表查询") @ApiOperation(value="tasks-分页列表查询", notes="tasks-分页列表查询")
@GetMapping(value = "/list") @GetMapping(value = "/list")
public Result<IPage<PendingTask>> queryPageList(PendingTask pendingTask, public Result<IPage<Task>> queryPageList(Task task,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo, @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize, @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
HttpServletRequest req) { HttpServletRequest req) {
QueryWrapper<PendingTask> queryWrapper = QueryGenerator.initQueryWrapper(pendingTask, req.getParameterMap()); QueryWrapper<Task> queryWrapper = QueryGenerator.initQueryWrapper(task, req.getParameterMap());
Page<PendingTask> page = new Page<PendingTask>(pageNo, pageSize); Page<Task> page = new Page<Task>(pageNo, pageSize);
IPage<PendingTask> pageList = pendingTaskService.page(page, queryWrapper); IPage<Task> pageList = taskService.page(page, queryWrapper);
return Result.OK(pageList); return Result.OK(pageList);
} }
/** /**
* *
* *
* @param pendingTask * @param task
* @return * @return
*/ */
@AutoLog(value = "to know if a task in launched-添加") @AutoLog(value = "tasks-添加")
@ApiOperation(value="to know if a task in launched-添加", notes="to know if a task in launched-添加") @ApiOperation(value="tasks-添加", notes="tasks-添加")
@RequiresPermissions("business:task:add")
@PostMapping(value = "/add") @PostMapping(value = "/add")
public Result<String> add(@RequestBody PendingTask pendingTask) { public Result<String> add(@RequestBody Task task) {
pendingTaskService.save(pendingTask); taskService.save(task);
return Result.OK("添加成功!"); return Result.OK("添加成功!");
} }
/** /**
* *
* *
* @param pendingTask * @param task
* @return * @return
*/ */
@AutoLog(value = "to know if a task in launched-编辑") @AutoLog(value = "tasks-编辑")
@ApiOperation(value="to know if a task in launched-编辑", notes="to know if a task in launched-编辑") @ApiOperation(value="tasks-编辑", notes="tasks-编辑")
@RequiresPermissions("business:task:edit")
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST}) @RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
public Result<String> edit(@RequestBody PendingTask pendingTask) { public Result<String> edit(@RequestBody Task task) {
pendingTaskService.updateById(pendingTask); taskService.updateById(task);
return Result.OK("编辑成功!"); return Result.OK("编辑成功!");
} }
/** /**
* id * id
* *
* @param id * @param id
* @return * @return
*/ */
@AutoLog(value = "to know if a task in launched-通过id删除") @AutoLog(value = "tasks-通过id删除")
@ApiOperation(value="to know if a task in launched-通过id删除", notes="to know if a task in launched-通过id删除") @ApiOperation(value="tasks-通过id删除", notes="tasks-通过id删除")
@RequiresPermissions("business:task:delete")
@DeleteMapping(value = "/delete") @DeleteMapping(value = "/delete")
public Result<String> delete(@RequestParam(name="id",required=true) String id) { public Result<String> delete(@RequestParam(name="id",required=true) String id) {
pendingTaskService.removeById(id); taskService.removeById(id);
return Result.OK("删除成功!"); return Result.OK("删除成功!");
} }
/** /**
* *
* *
* @param ids * @param ids
* @return * @return
*/ */
@AutoLog(value = "to know if a task in launched-批量删除") @AutoLog(value = "tasks-批量删除")
@ApiOperation(value="to know if a task in launched-批量删除", notes="to know if a task in launched-批量删除") @ApiOperation(value="tasks-批量删除", notes="tasks-批量删除")
@RequiresPermissions("business:task:deleteBatch")
@DeleteMapping(value = "/deleteBatch") @DeleteMapping(value = "/deleteBatch")
public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) { public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
this.pendingTaskService.removeByIds(Arrays.asList(ids.split(","))); this.taskService.removeByIds(Arrays.asList(ids.split(",")));
return Result.OK("批量删除成功!"); return Result.OK("批量删除成功!");
} }
/** /**
* id * id
* *
* @param id * @param id
* @return * @return
*/ */
//@AutoLog(value = "to know if a task in launched-通过id查询") //@AutoLog(value = "tasks-通过id查询")
@ApiOperation(value="to know if a task in launched-通过id查询", notes="to know if a task in launched-通过id查询") @ApiOperation(value="tasks-通过id查询", notes="tasks-通过id查询")
@GetMapping(value = "/queryById") @GetMapping(value = "/queryById")
public Result<PendingTask> queryById(@RequestParam(name="id",required=true) String id) { public Result<Task> queryById(@RequestParam(name="id",required=true) String id) {
PendingTask pendingTask = pendingTaskService.getById(id); Task task = taskService.getById(id);
if(pendingTask==null) { if(task==null) {
return Result.error("未找到对应数据"); return Result.error("未找到对应数据");
} }
return Result.OK(pendingTask); return Result.OK(task);
} }
/** /**
* excel * excel
* *
* @param request * @param request
* @param pendingTask * @param task
*/ */
@RequiresPermissions("business:task:exportXls")
@RequestMapping(value = "/exportXls") @RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, PendingTask pendingTask) { public ModelAndView exportXls(HttpServletRequest request, Task task) {
return super.exportXls(request, pendingTask, PendingTask.class, "to know if a task in launched"); return super.exportXls(request, task, Task.class, "tasks");
} }
/** /**
@ -164,14 +169,10 @@ public class PendingTaskController extends JeecgController<PendingTask, IPending
* @param response * @param response
* @return * @return
*/ */
@RequiresPermissions("business:task:importExcel")
@RequestMapping(value = "/importExcel", method = RequestMethod.POST) @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) { public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
return super.importExcel(request, response, PendingTask.class); return super.importExcel(request, response, Task.class);
} }
@PostMapping(value = "/reset")
public Result<?> resetTask(@RequestBody String taskCode) {
pendingTaskService.setStatus(0, "BI");
return Result.ok("Reset successful !");
}
} }

View File

@ -0,0 +1,171 @@
package org.jeecg.modules.business.controller.admin;
import java.util.Arrays;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.modules.business.entity.TaskHistory;
import org.jeecg.modules.business.service.ITaskHistoryService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.system.base.controller.JeecgController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.aspect.annotation.AutoLog;
/**
* @Description: task history
* @Author: jeecg-boot
* @Date: 2023-08-22
* @Version: V1.0
*/
@Api(tags="taskHistory")
@RestController
@RequestMapping("/taskHistory")
@Slf4j
public class TaskHistoryController extends JeecgController<TaskHistory, ITaskHistoryService> {
@Autowired
private ITaskHistoryService taskHistoryService;
/**
*
*
* @param taskHistory
* @param pageNo
* @param pageSize
* @param req
* @return
*/
//@AutoLog(value = "task history-分页列表查询")
@ApiOperation(value="task history-分页列表查询", notes="task history-分页列表查询")
@GetMapping(value = "/list")
public Result<IPage<TaskHistory>> queryPageList(TaskHistory taskHistory,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
HttpServletRequest req) {
QueryWrapper<TaskHistory> queryWrapper = QueryGenerator.initQueryWrapper(taskHistory, req.getParameterMap());
Page<TaskHistory> page = new Page<TaskHistory>(pageNo, pageSize);
IPage<TaskHistory> pageList = taskHistoryService.page(page, queryWrapper);
return Result.OK(pageList);
}
/**
*
*
* @param taskHistory
* @return
*/
@AutoLog(value = "task history-添加")
@ApiOperation(value="task history-添加", notes="task history-添加")
@PostMapping(value = "/add")
public Result<String> add(@RequestBody TaskHistory taskHistory) {
taskHistoryService.save(taskHistory);
return Result.OK("添加成功!");
}
/**
*
*
* @param taskHistory
* @return
*/
@AutoLog(value = "task history-编辑")
@ApiOperation(value="task history-编辑", notes="task history-编辑")
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
public Result<String> edit(@RequestBody TaskHistory taskHistory) {
taskHistoryService.updateById(taskHistory);
return Result.OK("编辑成功!");
}
/**
* id
*
* @param id
* @return
*/
@AutoLog(value = "task history-通过id删除")
@ApiOperation(value="task history-通过id删除", notes="task history-通过id删除")
@DeleteMapping(value = "/delete")
public Result<String> delete(@RequestParam(name="id",required=true) String id) {
taskHistoryService.removeById(id);
return Result.OK("删除成功!");
}
/**
*
*
* @param ids
* @return
*/
@AutoLog(value = "task history-批量删除")
@ApiOperation(value="task history-批量删除", notes="task history-批量删除")
@DeleteMapping(value = "/deleteBatch")
public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
this.taskHistoryService.removeByIds(Arrays.asList(ids.split(",")));
return Result.OK("批量删除成功!");
}
/**
* id
*
* @param id
* @return
*/
//@AutoLog(value = "task history-通过id查询")
@ApiOperation(value="task history-通过id查询", notes="task history-通过id查询")
@GetMapping(value = "/queryById")
public Result<TaskHistory> queryById(@RequestParam(name="id",required=true) String id) {
TaskHistory taskHistory = taskHistoryService.getById(id);
if(taskHistory==null) {
return Result.error("未找到对应数据");
}
return Result.OK(taskHistory);
}
/**
* excel
*
* @param request
* @param taskHistory
*/
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, TaskHistory taskHistory) {
return super.exportXls(request, taskHistory, TaskHistory.class, "task history");
}
/**
* excel
*
* @param request
* @param response
* @return
*/
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
return super.importExcel(request, response, TaskHistory.class);
}
/**
* Reset sets all running tasks to -1
* @param taskCode code of task
* @return
*/
@GetMapping(value = "/reset")
public Result<?> resetTask(@RequestParam("task") String taskCode) {
List<TaskHistory> allRunningTasks = taskHistoryService.getAllRunningTasksByCode(taskCode);
for(TaskHistory taskHistory: allRunningTasks) {
taskHistory.setOngoing(-1);
taskHistoryService.updateById(taskHistory);
}
return Result.ok("Reset successful !");
}
}

View File

@ -35,15 +35,11 @@ import javax.servlet.http.HttpServletRequest;
import java.io.*; import java.io.*;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.text.ParseException; import java.text.ParseException;
import java.util.*; import java.util.*;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
/** /**
* Controller for request related to shipping invoice * Controller for request related to shipping invoice
@ -74,7 +70,9 @@ public class InvoiceController {
@Autowired @Autowired
private IQuartzJobService quartzJobService; private IQuartzJobService quartzJobService;
@Autowired @Autowired
private IPendingTaskService pendingTaskService; private ITaskService pendingTaskService;
@Autowired
private ITaskHistoryService taskHistoryService;
@Autowired @Autowired
private FreeMarkerConfigurer freemarkerConfigurer; private FreeMarkerConfigurer freemarkerConfigurer;
@Autowired @Autowired
@ -460,11 +458,15 @@ public class InvoiceController {
public Result<?> makeBreakdownInvoice(@RequestParam(value = "shipping[]", required = false) List<String> shippingClientIds, public Result<?> makeBreakdownInvoice(@RequestParam(value = "shipping[]", required = false) List<String> shippingClientIds,
@RequestParam(value = "complete[]", required = false) List<String> completeClientIds) throws IOException { @RequestParam(value = "complete[]", required = false) List<String> completeClientIds) throws IOException {
List<InvoiceMetaData> metaDataErrorList = new ArrayList<>(); List<InvoiceMetaData> metaDataErrorList = new ArrayList<>();
if(pendingTaskService.getStatus("BI").equals("1")) { TaskHistory ongoingBITask = taskHistoryService.getLatestRunningTask("BI");
return Result.error("Task is already running, please retry in a moment !"); if(ongoingBITask != null) {
return Result.error("Task is already run by " + ongoingBITask.getCreateBy() + ", please retry in a moment !");
} }
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
List<InvoiceMetaData> invoiceList = new ArrayList<>(); List<InvoiceMetaData> invoiceList = new ArrayList<>();
pendingTaskService.setStatus(1, "BI"); taskHistoryService.insert(new TaskHistory(sysUser.getUsername(), 1, "BI"));
TaskHistory lastRunningTask = taskHistoryService.getLatestRunningTask("BI");
if(shippingClientIds != null) { if(shippingClientIds != null) {
log.info("Making shipping invoice for clients : {}", shippingClientIds); log.info("Making shipping invoice for clients : {}", shippingClientIds);
invoiceList.addAll(shippingInvoiceService.breakdownInvoiceClientByType(shippingClientIds, 0)); invoiceList.addAll(shippingInvoiceService.breakdownInvoiceClientByType(shippingClientIds, 0));
@ -490,7 +492,6 @@ public class InvoiceController {
} }
log.info("Generating detail files ...{}/{}", cpt++, invoiceList.size()); log.info("Generating detail files ...{}/{}", cpt++, invoiceList.size());
} }
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
String zipFilename = shippingInvoiceService.zipInvoices(filenameList); String zipFilename = shippingInvoiceService.zipInvoices(filenameList);
String subject = "Invoices generated from Breakdown Page"; String subject = "Invoices generated from Breakdown Page";
String destEmail = sysUser.getEmail(); String destEmail = sysUser.getEmail();
@ -512,17 +513,21 @@ public class InvoiceController {
emailService.sendMessageWithAttachment(destEmail, subject, htmlBody, zipFilename,session); emailService.sendMessageWithAttachment(destEmail, subject, htmlBody, zipFilename,session);
log.info("Mail sent successfully"); log.info("Mail sent successfully");
pendingTaskService.setStatus(0, "BI"); lastRunningTask.setOngoing(0);
taskHistoryService.updateById(lastRunningTask);
return Result.OK("component.email.emailSent"); return Result.OK("component.email.emailSent");
} }
catch(Exception e) { catch(Exception e) {
e.printStackTrace(); e.printStackTrace();
lastRunningTask.setOngoing(-1);
taskHistoryService.updateById(lastRunningTask);
return Result.error("An error occurred while trying to send an email."); return Result.error("An error occurred while trying to send an email.");
} }
} }
lastRunningTask.setOngoing(0);
pendingTaskService.setStatus(0, "BI"); taskHistoryService.updateById(lastRunningTask);
return Result.ok(); return Result.ok("Nothing invoiced");
} }
/** /**

View File

@ -1,35 +1,26 @@
package org.jeecg.modules.business.entity; package org.jeecg.modules.business.entity;
import java.io.Serializable; import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.util.Date;
import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableLogic;
import lombok.Data; import lombok.Data;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
import org.jeecgframework.poi.excel.annotation.Excel; import org.jeecgframework.poi.excel.annotation.Excel;
import org.jeecg.common.aspect.annotation.Dict;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/** /**
* @Description: to know if a task in launched * @Description: tasks
* @Author: jeecg-boot * @Author: jeecg-boot
* @Date: 2023-08-17 * @Date: 2023-08-22
* @Version: V1.0 * @Version: V1.0
*/ */
@Data @Data
@TableName("pending_task") @TableName("task")
@Accessors(chain = true) @ApiModel(value="task对象", description="tasks")
@EqualsAndHashCode(callSuper = false) public class Task implements Serializable {
@ApiModel(value="pending_task对象", description="to know if a task in launched")
public class PendingTask implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/**主键*/ /**主键*/
@ -52,16 +43,16 @@ public class PendingTask implements Serializable {
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "更新日期") @ApiModelProperty(value = "更新日期")
private java.util.Date updateTime; private java.util.Date updateTime;
/**task name*/ /**taskCode*/
@Excel(name = "task name", width = 15) @Excel(name = "taskCode", width = 15)
@ApiModelProperty(value = "task name") @ApiModelProperty(value = "taskCode")
private java.lang.String code;
/**taskName*/
@Excel(name = "taskName", width = 15)
@ApiModelProperty(value = "taskName")
private java.lang.String name; private java.lang.String name;
/**description*/ /**description*/
@Excel(name = "description", width = 15) @Excel(name = "description", width = 15)
@ApiModelProperty(value = "description") @ApiModelProperty(value = "description")
private java.lang.String description; private java.lang.String description;
/**task status*/
@Excel(name = "task status", width = 15)
@ApiModelProperty(value = "task status")
private java.lang.String onGoing;
} }

View File

@ -0,0 +1,63 @@
package org.jeecg.modules.business.entity;
import java.io.Serializable;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;
import org.jeecgframework.poi.excel.annotation.Excel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* @Description: task history
* @Author: jeecg-boot
* @Date: 2023-08-22
* @Version: V1.0
*/
@Data
@TableName("task_history")
@ApiModel(value="task_history对象", description="task history")
public class TaskHistory implements Serializable {
private static final long serialVersionUID = 1L;
/**主键*/
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "主键")
private java.lang.String id;
/**创建人*/
@ApiModelProperty(value = "创建人")
private java.lang.String createBy;
/**创建日期*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "创建日期")
private java.util.Date createTime;
/**更新人*/
@ApiModelProperty(value = "更新人")
private java.lang.String updateBy;
/**更新日期*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "更新日期")
private java.util.Date updateTime;
/**ongoing*/
@Excel(name = "ongoing", width = 15)
@ApiModelProperty(value = "ongoing")
private java.lang.Integer ongoing;
/**task code*/
@Excel(name = "task code", width = 15)
@ApiModelProperty(value = "task id")
private java.lang.String taskCode;
public TaskHistory(String createBy, int ongoing, String taskCode) {
this.createBy = createBy;
this.ongoing = ongoing;
this.taskCode = taskCode;
}
public TaskHistory() {
}
}

View File

@ -1,21 +0,0 @@
package org.jeecg.modules.business.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.jeecg.modules.business.entity.PendingTask;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springframework.stereotype.Repository;
/**
* @Description: to know if a task in launched
* @Author: jeecg-boot
* @Date: 2023-08-17
* @Version: V1.0
*/
@Repository
public interface PendingTaskMapper extends BaseMapper<PendingTask> {
void setStatus(@Param("status") int status, @Param("code") String taskCode);
String getStatus(@Param("code") String taskCode);
}

View File

@ -0,0 +1,23 @@
package org.jeecg.modules.business.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.jeecg.modules.business.entity.TaskHistory;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springframework.stereotype.Repository;
/**
* @Description: task history
* @Author: jeecg-boot
* @Date: 2023-08-22
* @Version: V1.0
*/
@Repository
public interface TaskHistoryMapper extends BaseMapper<TaskHistory> {
TaskHistory getLatestRunningTask(@Param("code") String taskCode);
List<TaskHistory> getAllRunningTasks(@Param("code") String taskCode);
}

View File

@ -0,0 +1,14 @@
package org.jeecg.modules.business.mapper;
import org.jeecg.modules.business.entity.Task;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @Description: tasks
* @Author: jeecg-boot
* @Date: 2023-08-22
* @Version: V1.0
*/
public interface TaskMapper extends BaseMapper<Task> {
}

View File

@ -1,14 +0,0 @@
<?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.jeecg.modules.business.mapper.PendingTaskMapper">
<update id="setStatus">
UPDATE pending_task
SET on_going = #{status}
WHERE code = #{code};
</update>
<select id="getStatus" resultType="java.lang.String">
SELECT on_going
FROM pending_task
WHERE code = #{code};
</select>
</mapper>

View File

@ -0,0 +1,17 @@
<?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.jeecg.modules.business.mapper.TaskHistoryMapper">
<select id="getLatestRunningTask" resultType="org.jeecg.modules.business.entity.TaskHistory">
SELECT id, create_by, create_time, update_by, update_time, ongoing, task_code FROM task_history
WHERE task_code = #{code}
AND ongoing = 1
ORDER BY create_time DESC
LIMIT 1;
</select>
<select id="getAllRunningTasks" resultType="org.jeecg.modules.business.entity.TaskHistory">
SELECT id, create_by, create_time, update_by, update_time, ongoing, task_code FROM task_history
WHERE task_code = #{code}
AND ongoing = 1;
</select>
</mapper>

View File

@ -0,0 +1,5 @@
<?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.jeecg.modules.business.mapper.TaskMapper">
</mapper>

View File

@ -1,15 +0,0 @@
package org.jeecg.modules.business.service;
import org.jeecg.modules.business.entity.PendingTask;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @Description: to know if a task in launched
* @Author: jeecg-boot
* @Date: 2023-08-17
* @Version: V1.0
*/
public interface IPendingTaskService extends IService<PendingTask> {
void setStatus(int status, String taskCode);
String getStatus(String taskCode);
}

View File

@ -0,0 +1,21 @@
package org.jeecg.modules.business.service;
import org.jeecg.modules.business.entity.TaskHistory;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
* @Description: task history
* @Author: jeecg-boot
* @Date: 2023-08-22
* @Version: V1.0
*/
public interface ITaskHistoryService extends IService<TaskHistory> {
TaskHistory getLatestRunningTask(String taskCode);
List<TaskHistory> getAllRunningTasksByCode(String bi);
void insert(TaskHistory taskHistory);
}

View File

@ -0,0 +1,14 @@
package org.jeecg.modules.business.service;
import org.jeecg.modules.business.entity.Task;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @Description: tasks
* @Author: jeecg-boot
* @Date: 2023-08-22
* @Version: V1.0
*/
public interface ITaskService extends IService<Task> {
}

View File

@ -1,32 +0,0 @@
package org.jeecg.modules.business.service.impl;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.modules.business.entity.PendingTask;
import org.jeecg.modules.business.mapper.PendingTaskMapper;
import org.jeecg.modules.business.service.IPendingTaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
/**
* @Description: to know if a task in launched
* @Author: jeecg-boot
* @Date: 2023-08-17
* @Version: V1.0
*/
@Service
@Slf4j
public class PendingTaskServiceImpl extends ServiceImpl<PendingTaskMapper, PendingTask> implements IPendingTaskService {
@Autowired
private PendingTaskMapper pendingTaskMapper;
@Override
public void setStatus(int status, String taskCode) {
pendingTaskMapper.setStatus(status, taskCode);
}
@Override
public String getStatus(String taskCode) {
return pendingTaskMapper.getStatus(taskCode);
}
}

View File

@ -0,0 +1,40 @@
package org.jeecg.modules.business.service.impl;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.modules.business.entity.TaskHistory;
import org.jeecg.modules.business.mapper.TaskHistoryMapper;
import org.jeecg.modules.business.service.ITaskHistoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.util.List;
/**
* @Description: task history
* @Author: jeecg-boot
* @Date: 2023-08-22
* @Version: V1.0
*/
@Slf4j
@Service
public class TaskHistoryServiceImpl extends ServiceImpl<TaskHistoryMapper, TaskHistory> implements ITaskHistoryService {
@Autowired
private TaskHistoryMapper taskHistoryMapper;
@Override
public TaskHistory getLatestRunningTask(String taskCode) {
return taskHistoryMapper.getLatestRunningTask(taskCode);
}
@Override
public List<TaskHistory> getAllRunningTasksByCode(String taskCode) {
return taskHistoryMapper.getAllRunningTasks(taskCode);
}
@Override
public void insert(TaskHistory taskHistory) {
taskHistoryMapper.insert(taskHistory);
}
}

View File

@ -0,0 +1,19 @@
package org.jeecg.modules.business.service.impl;
import org.jeecg.modules.business.entity.Task;
import org.jeecg.modules.business.mapper.TaskMapper;
import org.jeecg.modules.business.service.ITaskService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
/**
* @Description: tasks
* @Author: jeecg-boot
* @Date: 2023-08-22
* @Version: V1.0
*/
@Service
public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements ITaskService {
}