diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/controller/admin/PendingTaskController.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/controller/admin/TaskController.java similarity index 53% rename from jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/controller/admin/PendingTaskController.java rename to jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/controller/admin/TaskController.java index 305402f98..741fa0dae 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/controller/admin/PendingTaskController.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/controller/admin/TaskController.java @@ -12,8 +12,8 @@ import javax.servlet.http.HttpServletResponse; import org.jeecg.common.api.vo.Result; import org.jeecg.common.system.query.QueryGenerator; import org.jeecg.common.util.oConvertUtils; -import org.jeecg.modules.business.entity.PendingTask; -import org.jeecg.modules.business.service.IPendingTaskService; +import org.jeecg.modules.business.entity.Task; +import org.jeecg.modules.business.service.ITaskService; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 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; /** - * @Description: to know if a task in launched + * @Description: tasks * @Author: jeecg-boot - * @Date: 2023-08-17 + * @Date: 2023-08-22 * @Version: V1.0 */ -@Api(tags="pendingTask") +@Api(tags="tasks") @RestController -@RequestMapping("/pendingTask") +@RequestMapping("/business/task") @Slf4j -public class PendingTaskController extends JeecgController { +public class TaskController extends JeecgController { @Autowired - private IPendingTaskService pendingTaskService; - + private ITaskService taskService; + /** * 分页列表查询 * - * @param pendingTask + * @param task * @param pageNo * @param pageSize * @param req * @return */ - //@AutoLog(value = "to know if a task in launched-分页列表查询") - @ApiOperation(value="to know if a task in launched-分页列表查询", notes="to know if a task in launched-分页列表查询") + //@AutoLog(value = "tasks-分页列表查询") + @ApiOperation(value="tasks-分页列表查询", notes="tasks-分页列表查询") @GetMapping(value = "/list") - public Result> queryPageList(PendingTask pendingTask, + public Result> queryPageList(Task task, @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, HttpServletRequest req) { - QueryWrapper queryWrapper = QueryGenerator.initQueryWrapper(pendingTask, req.getParameterMap()); - Page page = new Page(pageNo, pageSize); - IPage pageList = pendingTaskService.page(page, queryWrapper); + QueryWrapper queryWrapper = QueryGenerator.initQueryWrapper(task, req.getParameterMap()); + Page page = new Page(pageNo, pageSize); + IPage pageList = taskService.page(page, queryWrapper); return Result.OK(pageList); } - + /** * 添加 * - * @param pendingTask + * @param task * @return */ - @AutoLog(value = "to know if a task in launched-添加") - @ApiOperation(value="to know if a task in launched-添加", notes="to know if a task in launched-添加") + @AutoLog(value = "tasks-添加") + @ApiOperation(value="tasks-添加", notes="tasks-添加") + @RequiresPermissions("business:task:add") @PostMapping(value = "/add") - public Result add(@RequestBody PendingTask pendingTask) { - pendingTaskService.save(pendingTask); + public Result add(@RequestBody Task task) { + taskService.save(task); return Result.OK("添加成功!"); } - + /** * 编辑 * - * @param pendingTask + * @param task * @return */ - @AutoLog(value = "to know if a task in launched-编辑") - @ApiOperation(value="to know if a task in launched-编辑", notes="to know if a task in launched-编辑") + @AutoLog(value = "tasks-编辑") + @ApiOperation(value="tasks-编辑", notes="tasks-编辑") + @RequiresPermissions("business:task:edit") @RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST}) - public Result edit(@RequestBody PendingTask pendingTask) { - pendingTaskService.updateById(pendingTask); + public Result edit(@RequestBody Task task) { + taskService.updateById(task); return Result.OK("编辑成功!"); } - + /** * 通过id删除 * * @param id * @return */ - @AutoLog(value = "to know if a task in launched-通过id删除") - @ApiOperation(value="to know if a task in launched-通过id删除", notes="to know if a task in launched-通过id删除") + @AutoLog(value = "tasks-通过id删除") + @ApiOperation(value="tasks-通过id删除", notes="tasks-通过id删除") + @RequiresPermissions("business:task:delete") @DeleteMapping(value = "/delete") public Result delete(@RequestParam(name="id",required=true) String id) { - pendingTaskService.removeById(id); + taskService.removeById(id); return Result.OK("删除成功!"); } - + /** * 批量删除 * * @param ids * @return */ - @AutoLog(value = "to know if a task in launched-批量删除") - @ApiOperation(value="to know if a task in launched-批量删除", notes="to know if a task in launched-批量删除") + @AutoLog(value = "tasks-批量删除") + @ApiOperation(value="tasks-批量删除", notes="tasks-批量删除") + @RequiresPermissions("business:task:deleteBatch") @DeleteMapping(value = "/deleteBatch") public Result 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("批量删除成功!"); } - + /** * 通过id查询 * * @param id * @return */ - //@AutoLog(value = "to know if a task in launched-通过id查询") - @ApiOperation(value="to know if a task in launched-通过id查询", notes="to know if a task in launched-通过id查询") + //@AutoLog(value = "tasks-通过id查询") + @ApiOperation(value="tasks-通过id查询", notes="tasks-通过id查询") @GetMapping(value = "/queryById") - public Result queryById(@RequestParam(name="id",required=true) String id) { - PendingTask pendingTask = pendingTaskService.getById(id); - if(pendingTask==null) { + public Result queryById(@RequestParam(name="id",required=true) String id) { + Task task = taskService.getById(id); + if(task==null) { return Result.error("未找到对应数据"); } - return Result.OK(pendingTask); + return Result.OK(task); } /** * 导出excel * * @param request - * @param pendingTask + * @param task */ + @RequiresPermissions("business:task:exportXls") @RequestMapping(value = "/exportXls") - public ModelAndView exportXls(HttpServletRequest request, PendingTask pendingTask) { - return super.exportXls(request, pendingTask, PendingTask.class, "to know if a task in launched"); + public ModelAndView exportXls(HttpServletRequest request, Task task) { + return super.exportXls(request, task, Task.class, "tasks"); } /** @@ -164,14 +169,10 @@ public class PendingTaskController extends JeecgController 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 !"); - } } diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/controller/admin/TaskHistoryController.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/controller/admin/TaskHistoryController.java new file mode 100644 index 000000000..69032497d --- /dev/null +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/controller/admin/TaskHistoryController.java @@ -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 { + @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> queryPageList(TaskHistory taskHistory, + @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, + @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, + HttpServletRequest req) { + QueryWrapper queryWrapper = QueryGenerator.initQueryWrapper(taskHistory, req.getParameterMap()); + Page page = new Page(pageNo, pageSize); + IPage 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 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 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 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 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 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 allRunningTasks = taskHistoryService.getAllRunningTasksByCode(taskCode); + for(TaskHistory taskHistory: allRunningTasks) { + taskHistory.setOngoing(-1); + taskHistoryService.updateById(taskHistory); + } + return Result.ok("Reset successful !"); + } +} diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/controller/admin/shippingInvoice/InvoiceController.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/controller/admin/shippingInvoice/InvoiceController.java index 0b7dd6ed5..c9f04583a 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/controller/admin/shippingInvoice/InvoiceController.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/controller/admin/shippingInvoice/InvoiceController.java @@ -35,15 +35,11 @@ import javax.servlet.http.HttpServletRequest; import java.io.*; import java.math.BigDecimal; import java.math.RoundingMode; -import java.nio.file.Path; -import java.nio.file.Paths; import java.text.ParseException; import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; -import java.util.zip.ZipEntry; -import java.util.zip.ZipOutputStream; /** * Controller for request related to shipping invoice @@ -74,7 +70,9 @@ public class InvoiceController { @Autowired private IQuartzJobService quartzJobService; @Autowired - private IPendingTaskService pendingTaskService; + private ITaskService pendingTaskService; + @Autowired + private ITaskHistoryService taskHistoryService; @Autowired private FreeMarkerConfigurer freemarkerConfigurer; @Autowired @@ -460,11 +458,15 @@ public class InvoiceController { public Result makeBreakdownInvoice(@RequestParam(value = "shipping[]", required = false) List shippingClientIds, @RequestParam(value = "complete[]", required = false) List completeClientIds) throws IOException { List metaDataErrorList = new ArrayList<>(); - if(pendingTaskService.getStatus("BI").equals("1")) { - return Result.error("Task is already running, please retry in a moment !"); + TaskHistory ongoingBITask = taskHistoryService.getLatestRunningTask("BI"); + 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 invoiceList = new ArrayList<>(); - pendingTaskService.setStatus(1, "BI"); + taskHistoryService.insert(new TaskHistory(sysUser.getUsername(), 1, "BI")); + TaskHistory lastRunningTask = taskHistoryService.getLatestRunningTask("BI"); + if(shippingClientIds != null) { log.info("Making shipping invoice for clients : {}", shippingClientIds); invoiceList.addAll(shippingInvoiceService.breakdownInvoiceClientByType(shippingClientIds, 0)); @@ -490,7 +492,6 @@ public class InvoiceController { } log.info("Generating detail files ...{}/{}", cpt++, invoiceList.size()); } - LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); String zipFilename = shippingInvoiceService.zipInvoices(filenameList); String subject = "Invoices generated from Breakdown Page"; String destEmail = sysUser.getEmail(); @@ -512,17 +513,21 @@ public class InvoiceController { emailService.sendMessageWithAttachment(destEmail, subject, htmlBody, zipFilename,session); log.info("Mail sent successfully"); - pendingTaskService.setStatus(0, "BI"); + lastRunningTask.setOngoing(0); + taskHistoryService.updateById(lastRunningTask); return Result.OK("component.email.emailSent"); } catch(Exception e) { e.printStackTrace(); + + lastRunningTask.setOngoing(-1); + taskHistoryService.updateById(lastRunningTask); return Result.error("An error occurred while trying to send an email."); } } - - pendingTaskService.setStatus(0, "BI"); - return Result.ok(); + lastRunningTask.setOngoing(0); + taskHistoryService.updateById(lastRunningTask); + return Result.ok("Nothing invoiced"); } /** diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/entity/PendingTask.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/entity/Task.java similarity index 65% rename from jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/entity/PendingTask.java rename to jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/entity/Task.java index 70c275379..6420db583 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/entity/PendingTask.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/entity/Task.java @@ -1,35 +1,26 @@ package org.jeecg.modules.business.entity; 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.TableId; import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.annotation.TableLogic; import lombok.Data; import com.fasterxml.jackson.annotation.JsonFormat; import org.springframework.format.annotation.DateTimeFormat; import org.jeecgframework.poi.excel.annotation.Excel; -import org.jeecg.common.aspect.annotation.Dict; import io.swagger.annotations.ApiModel; 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 - * @Date: 2023-08-17 + * @Date: 2023-08-22 * @Version: V1.0 */ @Data -@TableName("pending_task") -@Accessors(chain = true) -@EqualsAndHashCode(callSuper = false) -@ApiModel(value="pending_task对象", description="to know if a task in launched") -public class PendingTask implements Serializable { +@TableName("task") +@ApiModel(value="task对象", description="tasks") +public class Task implements Serializable { private static final long serialVersionUID = 1L; /**主键*/ @@ -52,16 +43,16 @@ public class PendingTask implements Serializable { @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") @ApiModelProperty(value = "更新日期") private java.util.Date updateTime; - /**task name*/ - @Excel(name = "task name", width = 15) - @ApiModelProperty(value = "task name") + /**taskCode*/ + @Excel(name = "taskCode", width = 15) + @ApiModelProperty(value = "taskCode") + private java.lang.String code; + /**taskName*/ + @Excel(name = "taskName", width = 15) + @ApiModelProperty(value = "taskName") private java.lang.String name; /**description*/ @Excel(name = "description", width = 15) @ApiModelProperty(value = "description") private java.lang.String description; - /**task status*/ - @Excel(name = "task status", width = 15) - @ApiModelProperty(value = "task status") - private java.lang.String onGoing; } diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/entity/TaskHistory.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/entity/TaskHistory.java new file mode 100644 index 000000000..58c51ffdc --- /dev/null +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/entity/TaskHistory.java @@ -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() { + } +} diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/mapper/PendingTaskMapper.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/mapper/PendingTaskMapper.java deleted file mode 100644 index e3c649917..000000000 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/mapper/PendingTaskMapper.java +++ /dev/null @@ -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 { - void setStatus(@Param("status") int status, @Param("code") String taskCode); - String getStatus(@Param("code") String taskCode); -} diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/mapper/TaskHistoryMapper.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/mapper/TaskHistoryMapper.java new file mode 100644 index 000000000..b65d9c057 --- /dev/null +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/mapper/TaskHistoryMapper.java @@ -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 getLatestRunningTask(@Param("code") String taskCode); + + List getAllRunningTasks(@Param("code") String taskCode); +} diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/mapper/TaskMapper.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/mapper/TaskMapper.java new file mode 100644 index 000000000..cf3d7f134 --- /dev/null +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/mapper/TaskMapper.java @@ -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 { + +} diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/mapper/xml/PendingTaskMapper.xml b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/mapper/xml/PendingTaskMapper.xml deleted file mode 100644 index 90ad2c091..000000000 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/mapper/xml/PendingTaskMapper.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - UPDATE pending_task - SET on_going = #{status} - WHERE code = #{code}; - - - \ No newline at end of file diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/mapper/xml/TaskHistoryMapper.xml b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/mapper/xml/TaskHistoryMapper.xml new file mode 100644 index 000000000..9efc31a8c --- /dev/null +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/mapper/xml/TaskHistoryMapper.xml @@ -0,0 +1,17 @@ + + + + + + + \ No newline at end of file diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/mapper/xml/TaskMapper.xml b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/mapper/xml/TaskMapper.xml new file mode 100644 index 000000000..8c0b3fb24 --- /dev/null +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/mapper/xml/TaskMapper.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/IPendingTaskService.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/IPendingTaskService.java deleted file mode 100644 index e8840b6fb..000000000 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/IPendingTaskService.java +++ /dev/null @@ -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 { - void setStatus(int status, String taskCode); - String getStatus(String taskCode); -} diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/ITaskHistoryService.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/ITaskHistoryService.java new file mode 100644 index 000000000..0279cc840 --- /dev/null +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/ITaskHistoryService.java @@ -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 getLatestRunningTask(String taskCode); + + List getAllRunningTasksByCode(String bi); + + void insert(TaskHistory taskHistory); +} diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/ITaskService.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/ITaskService.java new file mode 100644 index 000000000..4a8f216f6 --- /dev/null +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/ITaskService.java @@ -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 { + +} diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/impl/PendingTaskServiceImpl.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/impl/PendingTaskServiceImpl.java deleted file mode 100644 index 899656666..000000000 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/impl/PendingTaskServiceImpl.java +++ /dev/null @@ -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 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); - } -} diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/impl/TaskHistoryServiceImpl.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/impl/TaskHistoryServiceImpl.java new file mode 100644 index 000000000..3e9a6092f --- /dev/null +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/impl/TaskHistoryServiceImpl.java @@ -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 implements ITaskHistoryService { + @Autowired + private TaskHistoryMapper taskHistoryMapper; + @Override + public TaskHistory getLatestRunningTask(String taskCode) { + return taskHistoryMapper.getLatestRunningTask(taskCode); + } + + @Override + public List getAllRunningTasksByCode(String taskCode) { + return taskHistoryMapper.getAllRunningTasks(taskCode); + } + + @Override + public void insert(TaskHistory taskHistory) { + taskHistoryMapper.insert(taskHistory); + } +} diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/impl/TaskServiceImpl.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/impl/TaskServiceImpl.java new file mode 100644 index 000000000..9139c1e9c --- /dev/null +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/impl/TaskServiceImpl.java @@ -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 implements ITaskService { + +}