Merge branch 'master' into branch_basic
This commit is contained in:
commit
ab7aef3c84
|
|
@ -5,6 +5,6 @@ package com.bonus.common.biz.constant;
|
||||||
* @author bonus
|
* @author bonus
|
||||||
*/
|
*/
|
||||||
public class BmConfigItems {
|
public class BmConfigItems {
|
||||||
public static final String LEASE_AUDIT_ROLE_KEYS = "LeaseAuditRoleKeys";
|
public static final String LEASE_TASK_AUDIT_ROLE_KEYS = "LeaseTaskAuditRoleKeys";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,13 @@ public class MaterialConstants
|
||||||
public static final String UTF8 = "UTF-8";
|
public static final String UTF8 = "UTF-8";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xls
|
<<<<<<< HEAD
|
||||||
|
* 领料任务类型
|
||||||
|
*/
|
||||||
|
public static final Long LEASE_TASK_TYPE = 2L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* XLS
|
||||||
*/
|
*/
|
||||||
public static final String XLS = "xls";
|
public static final String XLS = "xls";
|
||||||
|
|
||||||
|
|
@ -48,4 +54,5 @@ public class MaterialConstants
|
||||||
|
|
||||||
public static final String FOUR_CONSTANT = "4";
|
public static final String FOUR_CONSTANT = "4";
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -100,6 +100,11 @@
|
||||||
<version>24.10.0-SNAPSHOT</version>
|
<version>24.10.0-SNAPSHOT</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>junit</groupId>
|
||||||
|
<artifactId>junit</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -68,5 +68,5 @@ public interface IBmConfigService
|
||||||
*/
|
*/
|
||||||
public int deleteBmConfigById(Long id);
|
public int deleteBmConfigById(Long id);
|
||||||
|
|
||||||
public String getLeaseAuditRoleKeys();
|
public List<String> getLeaseTaskAuditRoleKeys();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,9 @@
|
||||||
package com.bonus.material.basic.service.impl;
|
package com.bonus.material.basic.service.impl;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import com.bonus.common.biz.constant.BmConfigItems;
|
import com.bonus.common.biz.constant.BmConfigItems;
|
||||||
import com.bonus.common.core.utils.DateUtils;
|
import com.bonus.common.core.utils.DateUtils;
|
||||||
|
|
@ -117,8 +120,15 @@ public class BmConfigServiceImpl implements IBmConfigService
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLeaseAuditRoleKeys() {
|
public List<String> getLeaseTaskAuditRoleKeys() {
|
||||||
String value = bmConfigMapper.selectBmConfigByItemName(BmConfigItems.LEASE_AUDIT_ROLE_KEYS).getItemValue();
|
List<String> list = new ArrayList();
|
||||||
return getValueWithDefault(value, "");
|
BmConfig bmConfig = bmConfigMapper.selectBmConfigByItemName(BmConfigItems.LEASE_TASK_AUDIT_ROLE_KEYS);
|
||||||
|
if (Objects.nonNull(bmConfig)) {
|
||||||
|
String value = getValueWithDefault(bmConfig.getItemValue(), "");
|
||||||
|
if (StringUtils.isNotEmpty(value)) {
|
||||||
|
list = Arrays.asList(value.split(","));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,50 @@
|
||||||
|
//package com.bonus.material.common.utils;
|
||||||
|
//
|
||||||
|
//import com.bonus.common.biz.constant.MaterialConstants;
|
||||||
|
//import com.bonus.material.basic.service.IBmConfigService;
|
||||||
|
//import com.bonus.material.task.domain.TmTaskAuditLogs;
|
||||||
|
//import com.bonus.material.task.domain.TmTaskAuditResult;
|
||||||
|
//import com.bonus.material.task.service.ITmTaskAuditLogsService;
|
||||||
|
//import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
//import org.springframework.util.CollectionUtils;
|
||||||
|
//import java.util.ArrayList;
|
||||||
|
//import java.util.List;
|
||||||
|
//
|
||||||
|
//public class AuditTool {
|
||||||
|
//
|
||||||
|
// @Autowired
|
||||||
|
// private IBmConfigService bmConfigService;
|
||||||
|
//
|
||||||
|
// @Autowired
|
||||||
|
// private ITmTaskAuditLogsService tmTaskAuditLogsService;
|
||||||
|
//
|
||||||
|
// public TmTaskAuditResult getAuditResult(Long taskId, Long taskType) {
|
||||||
|
// List<String> needRoles = new ArrayList<>();
|
||||||
|
// if (MaterialConstants.LEASE_TASK.equals(taskType)) {
|
||||||
|
// needRoles = bmConfigService.getLeaseTaskAuditRoleKeys();
|
||||||
|
// }
|
||||||
|
// //TODO, add more tasks logic to get needRoles
|
||||||
|
// if (CollectionUtils.isEmpty(needRoles)) {
|
||||||
|
// return new TmTaskAuditResult(true);
|
||||||
|
// } else {
|
||||||
|
// List<String> auditRoleKeys = tmTaskAuditLogsService.selectTmTaskAuditRoleKeyList(new TmTaskAuditLogs(taskId, taskType));
|
||||||
|
// String nextRole = needRoles.get(0);
|
||||||
|
// boolean isFinished = false;
|
||||||
|
// for (int i = 0; i < needRoles.size(); i++) {
|
||||||
|
// if (i < needRoles.size() - 1) {
|
||||||
|
// // 遍历,还没到最后一个
|
||||||
|
// if (auditRoleKeys.contains(needRoles.get(i))) {
|
||||||
|
// nextRole = needRoles.get(i + 1);
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// // 遍历,已经到最后一个了
|
||||||
|
// if (auditRoleKeys.contains(needRoles.get(i))) {
|
||||||
|
// nextRole = "";
|
||||||
|
// isFinished = true;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return new TmTaskAuditResult(isFinished, needRoles, nextRole);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
@ -0,0 +1,137 @@
|
||||||
|
package com.bonus.material.task.controller;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import com.bonus.common.log.enums.OperaType;
|
||||||
|
import com.bonus.material.common.annotation.PreventRepeatSubmit;
|
||||||
|
import com.bonus.material.task.domain.TmTaskAuditResult;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import com.bonus.common.log.annotation.SysLog;
|
||||||
|
import com.bonus.common.security.annotation.RequiresPermissions;
|
||||||
|
import com.bonus.material.task.domain.TmTaskAuditLog;
|
||||||
|
import com.bonus.material.task.service.ITmTaskAuditLogService;
|
||||||
|
import com.bonus.common.core.web.controller.BaseController;
|
||||||
|
import com.bonus.common.core.web.domain.AjaxResult;
|
||||||
|
import com.bonus.common.core.utils.poi.ExcelUtil;
|
||||||
|
import com.bonus.common.core.web.page.TableDataInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 任务Controller
|
||||||
|
*
|
||||||
|
* @author xsheng
|
||||||
|
* @date 2024-10-18
|
||||||
|
*/
|
||||||
|
@Api(tags = "任务接口")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/tm_task_audit_log")
|
||||||
|
public class TmTaskAuditLogController extends BaseController {
|
||||||
|
@Autowired
|
||||||
|
private ITmTaskAuditLogService tmTaskAuditLogsService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询任务列表
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "查询任务列表")
|
||||||
|
@RequiresPermissions("task:logs:list")
|
||||||
|
@GetMapping("/list")
|
||||||
|
public TableDataInfo list(TmTaskAuditLog tmTaskAuditLog) {
|
||||||
|
startPage();
|
||||||
|
List<TmTaskAuditLog> list = tmTaskAuditLogsService.selectTmTaskAuditLogsList(tmTaskAuditLog);
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出任务列表
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "导出任务列表")
|
||||||
|
@PreventRepeatSubmit
|
||||||
|
@RequiresPermissions("task:logs:export")
|
||||||
|
@SysLog(title = "任务", businessType = OperaType.EXPORT, logType = 1,module = "仓储管理->导出任务")
|
||||||
|
@PostMapping("/export")
|
||||||
|
public void export(HttpServletResponse response, TmTaskAuditLog tmTaskAuditLog) {
|
||||||
|
List<TmTaskAuditLog> list = tmTaskAuditLogsService.selectTmTaskAuditLogsList(tmTaskAuditLog);
|
||||||
|
ExcelUtil<TmTaskAuditLog> util = new ExcelUtil<TmTaskAuditLog>(TmTaskAuditLog.class);
|
||||||
|
util.exportExcel(response, list, "任务数据");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取任务详细信息
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "获取任务详细信息")
|
||||||
|
@RequiresPermissions("task:logs:query")
|
||||||
|
@GetMapping(value = "/{id}")
|
||||||
|
public AjaxResult getInfo(@PathVariable("id") Long id) {
|
||||||
|
return success(tmTaskAuditLogsService.selectTmTaskAuditLogsById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增任务
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "新增任务")
|
||||||
|
@PreventRepeatSubmit
|
||||||
|
@RequiresPermissions("task:logs:add")
|
||||||
|
@SysLog(title = "任务", businessType = OperaType.INSERT, logType = 1,module = "仓储管理->新增任务")
|
||||||
|
@PostMapping
|
||||||
|
public AjaxResult add(@RequestBody TmTaskAuditLog tmTaskAuditLog) {
|
||||||
|
try {
|
||||||
|
return toAjax(tmTaskAuditLogsService.insertTmTaskAuditLogs(tmTaskAuditLog));
|
||||||
|
} catch (Exception e) {
|
||||||
|
return error("系统错误, " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改任务
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "修改任务")
|
||||||
|
@PreventRepeatSubmit
|
||||||
|
@RequiresPermissions("task:logs:edit")
|
||||||
|
@SysLog(title = "任务", businessType = OperaType.UPDATE, logType = 1,module = "仓储管理->修改任务")
|
||||||
|
@PutMapping
|
||||||
|
public AjaxResult edit(@RequestBody TmTaskAuditLog tmTaskAuditLog) {
|
||||||
|
try {
|
||||||
|
return toAjax(tmTaskAuditLogsService.updateTmTaskAuditLogs(tmTaskAuditLog));
|
||||||
|
} catch (Exception e) {
|
||||||
|
return error("系统错误, " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除任务
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "删除任务")
|
||||||
|
@PreventRepeatSubmit
|
||||||
|
@RequiresPermissions("task:logs:remove")
|
||||||
|
@SysLog(title = "任务", businessType = OperaType.DELETE, logType = 1,module = "仓储管理->删除任务")
|
||||||
|
@DeleteMapping("/{ids}")
|
||||||
|
public AjaxResult remove(@PathVariable Long[] ids) {
|
||||||
|
return toAjax(tmTaskAuditLogsService.deleteTmTaskAuditLogsByIds(ids));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增任务
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "任务审核结果")
|
||||||
|
@PreventRepeatSubmit
|
||||||
|
@RequiresPermissions("task:logs:audits")
|
||||||
|
@SysLog(title = "任务审核结果", businessType = OperaType.INSERT, logType = 1,module = "仓储管理->任务审核结果")
|
||||||
|
@PostMapping("/audits")
|
||||||
|
public AjaxResult queryTaskAudits(@RequestBody TmTaskAuditLog tmTaskAuditLog) {
|
||||||
|
try {
|
||||||
|
TmTaskAuditResult tmTaskAuditResult = tmTaskAuditLogsService.getAuditResult(tmTaskAuditLog);
|
||||||
|
return success(tmTaskAuditResult);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return error("系统错误, " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,40 @@
|
||||||
|
package com.bonus.material.task.domain;
|
||||||
|
|
||||||
|
import com.bonus.common.core.annotation.Excel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.ToString;
|
||||||
|
import com.bonus.common.core.web.domain.BaseEntity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 任务对象 tm_task_audit_log
|
||||||
|
*
|
||||||
|
* @author xsheng
|
||||||
|
* @date 2024-10-18
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@ToString
|
||||||
|
public class TmTaskAuditLog extends BaseEntity {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** 主键ID */
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/** 任务ID */
|
||||||
|
@Excel(name = "任务ID")
|
||||||
|
@ApiModelProperty(value = "任务ID")
|
||||||
|
private Long taskId;
|
||||||
|
|
||||||
|
/** 任务类型(定义数据字典) */
|
||||||
|
@Excel(name = "任务类型(定义数据字典)")
|
||||||
|
@ApiModelProperty(value = "任务类型(定义数据字典)")
|
||||||
|
private Long taskType;
|
||||||
|
|
||||||
|
/** 角色权限字符串 */
|
||||||
|
@Excel(name = "角色权限字符串")
|
||||||
|
@ApiModelProperty(value = "角色权限字符串")
|
||||||
|
private String roleKey;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
package com.bonus.material.task.domain;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class TmTaskAuditResult {
|
||||||
|
private boolean finished;
|
||||||
|
private List auditRoles;
|
||||||
|
private String nextRole;
|
||||||
|
|
||||||
|
public TmTaskAuditResult(boolean finished) {
|
||||||
|
this.finished = finished;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TmTaskAuditResult(boolean finished, List auditRoles, String nextRole) {
|
||||||
|
this.finished = finished;
|
||||||
|
this.auditRoles = auditRoles;
|
||||||
|
this.nextRole = nextRole;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,68 @@
|
||||||
|
package com.bonus.material.task.mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import com.bonus.material.task.domain.TmTaskAuditLog;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 任务Mapper接口
|
||||||
|
*
|
||||||
|
* @author xsheng
|
||||||
|
* @date 2024-10-18
|
||||||
|
*/
|
||||||
|
public interface TmTaskAuditLogMapper {
|
||||||
|
/**
|
||||||
|
* 查询任务
|
||||||
|
*
|
||||||
|
* @param id 任务主键
|
||||||
|
* @return 任务
|
||||||
|
*/
|
||||||
|
public TmTaskAuditLog selectTmTaskAuditLogById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询任务列表
|
||||||
|
*
|
||||||
|
* @param tmTaskAuditLog 任务
|
||||||
|
* @return 任务集合
|
||||||
|
*/
|
||||||
|
public List<TmTaskAuditLog> selectTmTaskAuditLogList(TmTaskAuditLog tmTaskAuditLog);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询任务列表已审核roleKeys
|
||||||
|
*
|
||||||
|
* @param tmTaskAuditLog 任务
|
||||||
|
* @return 任务集合
|
||||||
|
*/
|
||||||
|
public List<String> selectTmTaskAuditRoleKeyList(TmTaskAuditLog tmTaskAuditLog);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增任务
|
||||||
|
*
|
||||||
|
* @param tmTaskAuditLog 任务
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int insertTmTaskAuditLog(TmTaskAuditLog tmTaskAuditLog);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改任务
|
||||||
|
*
|
||||||
|
* @param tmTaskAuditLog 任务
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int updateTmTaskAuditLog(TmTaskAuditLog tmTaskAuditLog);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除任务
|
||||||
|
*
|
||||||
|
* @param id 任务主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteTmTaskAuditLogById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除任务
|
||||||
|
*
|
||||||
|
* @param ids 需要删除的数据主键集合
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteTmTaskAuditLogsByIds(Long[] ids);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,71 @@
|
||||||
|
package com.bonus.material.task.service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import com.bonus.material.task.domain.TmTaskAuditLog;
|
||||||
|
import com.bonus.material.task.domain.TmTaskAuditResult;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 任务Service接口
|
||||||
|
*
|
||||||
|
* @author xsheng
|
||||||
|
* @date 2024-10-18
|
||||||
|
*/
|
||||||
|
public interface ITmTaskAuditLogService {
|
||||||
|
/**
|
||||||
|
* 查询任务
|
||||||
|
*
|
||||||
|
* @param id 任务主键
|
||||||
|
* @return 任务
|
||||||
|
*/
|
||||||
|
public TmTaskAuditLog selectTmTaskAuditLogsById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询任务列表
|
||||||
|
*
|
||||||
|
* @param tmTaskAuditLog 任务
|
||||||
|
* @return 任务集合
|
||||||
|
*/
|
||||||
|
public List<TmTaskAuditLog> selectTmTaskAuditLogsList(TmTaskAuditLog tmTaskAuditLog);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询任务列表已审核的RoleKeys
|
||||||
|
*
|
||||||
|
* @param tmTaskAuditLog 任务
|
||||||
|
* @return 任务集合
|
||||||
|
*/
|
||||||
|
public List<String> selectTmTaskAuditRoleKeyList(TmTaskAuditLog tmTaskAuditLog);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增任务
|
||||||
|
*
|
||||||
|
* @param tmTaskAuditLog 任务
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int insertTmTaskAuditLogs(TmTaskAuditLog tmTaskAuditLog);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改任务
|
||||||
|
*
|
||||||
|
* @param tmTaskAuditLog 任务
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int updateTmTaskAuditLogs(TmTaskAuditLog tmTaskAuditLog);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除任务
|
||||||
|
*
|
||||||
|
* @param ids 需要删除的任务主键集合
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteTmTaskAuditLogsByIds(Long[] ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除任务信息
|
||||||
|
*
|
||||||
|
* @param id 任务主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteTmTaskAuditLogsById(Long id);
|
||||||
|
|
||||||
|
public TmTaskAuditResult getAuditResult(TmTaskAuditLog tmTaskAuditLog);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,147 @@
|
||||||
|
package com.bonus.material.task.service.impl;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.bonus.common.biz.constant.MaterialConstants;
|
||||||
|
import com.bonus.common.core.exception.ServiceException;
|
||||||
|
import com.bonus.common.core.utils.DateUtils;
|
||||||
|
import com.bonus.material.basic.service.IBmConfigService;
|
||||||
|
import com.bonus.material.task.domain.TmTaskAuditResult;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import com.bonus.material.task.mapper.TmTaskAuditLogMapper;
|
||||||
|
import com.bonus.material.task.domain.TmTaskAuditLog;
|
||||||
|
import com.bonus.material.task.service.ITmTaskAuditLogService;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 任务Service业务层处理
|
||||||
|
*
|
||||||
|
* @author xsheng
|
||||||
|
* @date 2024-10-18
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class TmTaskAuditLogServiceImpl implements ITmTaskAuditLogService {
|
||||||
|
@Autowired
|
||||||
|
private TmTaskAuditLogMapper tmTaskAuditLogsMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IBmConfigService bmConfigService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询任务
|
||||||
|
*
|
||||||
|
* @param id 任务主键
|
||||||
|
* @return 任务
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public TmTaskAuditLog selectTmTaskAuditLogsById(Long id) {
|
||||||
|
return tmTaskAuditLogsMapper.selectTmTaskAuditLogById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询任务列表
|
||||||
|
*
|
||||||
|
* @param tmTaskAuditLog 任务
|
||||||
|
* @return 任务
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<TmTaskAuditLog> selectTmTaskAuditLogsList(TmTaskAuditLog tmTaskAuditLog) {
|
||||||
|
return tmTaskAuditLogsMapper.selectTmTaskAuditLogList(tmTaskAuditLog);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询任务列表已审核的RoleKey
|
||||||
|
*
|
||||||
|
* @param tmTaskAuditLog 任务
|
||||||
|
* @return 任务集合
|
||||||
|
*/
|
||||||
|
public List<String> selectTmTaskAuditRoleKeyList(TmTaskAuditLog tmTaskAuditLog) {
|
||||||
|
return tmTaskAuditLogsMapper.selectTmTaskAuditRoleKeyList(tmTaskAuditLog);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增任务
|
||||||
|
*
|
||||||
|
* @param tmTaskAuditLog 任务
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int insertTmTaskAuditLogs(TmTaskAuditLog tmTaskAuditLog) {
|
||||||
|
tmTaskAuditLog.setCreateTime(DateUtils.getNowDate());
|
||||||
|
try {
|
||||||
|
return tmTaskAuditLogsMapper.insertTmTaskAuditLog(tmTaskAuditLog);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new ServiceException("错误信息描述");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改任务
|
||||||
|
*
|
||||||
|
* @param tmTaskAuditLog 任务
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int updateTmTaskAuditLogs(TmTaskAuditLog tmTaskAuditLog) {
|
||||||
|
tmTaskAuditLog.setUpdateTime(DateUtils.getNowDate());
|
||||||
|
try {
|
||||||
|
return tmTaskAuditLogsMapper.updateTmTaskAuditLog(tmTaskAuditLog);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new ServiceException("错误信息描述");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除任务
|
||||||
|
*
|
||||||
|
* @param ids 需要删除的任务主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int deleteTmTaskAuditLogsByIds(Long[] ids) {
|
||||||
|
return tmTaskAuditLogsMapper.deleteTmTaskAuditLogsByIds(ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除任务信息
|
||||||
|
*
|
||||||
|
* @param id 任务主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int deleteTmTaskAuditLogsById(Long id) {
|
||||||
|
return tmTaskAuditLogsMapper.deleteTmTaskAuditLogById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TmTaskAuditResult getAuditResult(TmTaskAuditLog tmTaskAuditLog) {
|
||||||
|
List<String> needRoles = new ArrayList<>();
|
||||||
|
if (MaterialConstants.LEASE_TASK_TYPE.equals(tmTaskAuditLog.getTaskType())) {
|
||||||
|
needRoles = bmConfigService.getLeaseTaskAuditRoleKeys();
|
||||||
|
}
|
||||||
|
//TODO, add more tasks logic to get needRoles
|
||||||
|
if (CollectionUtils.isEmpty(needRoles)) {
|
||||||
|
return new TmTaskAuditResult(true);
|
||||||
|
} else {
|
||||||
|
List<String> auditRoleKeys = selectTmTaskAuditRoleKeyList(tmTaskAuditLog);
|
||||||
|
String nextRole = needRoles.get(0);
|
||||||
|
boolean finished = false;
|
||||||
|
for (int i = 0; i < needRoles.size(); i++) {
|
||||||
|
if (i < needRoles.size() - 1) {
|
||||||
|
// 遍历,还没到最后一个
|
||||||
|
if (auditRoleKeys.contains(needRoles.get(i))) {
|
||||||
|
nextRole = needRoles.get(i + 1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 遍历,已经到最后一个了
|
||||||
|
if (auditRoleKeys.contains(needRoles.get(i))) {
|
||||||
|
nextRole = "";
|
||||||
|
finished = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new TmTaskAuditResult(finished, needRoles, nextRole);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -32,7 +32,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
|
||||||
<select id="selectBmConfigByItemName" parameterType="String" resultMap="BmConfigResult">
|
<select id="selectBmConfigByItemName" parameterType="String" resultMap="BmConfigResult">
|
||||||
<include refid="selectBmConfigVo"/>
|
<include refid="selectBmConfigVo"/>
|
||||||
where itemName = #{itemName}
|
where item_name = #{itemName}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<insert id="insertBmConfig" parameterType="com.bonus.material.basic.domain.BmConfig" useGeneratedKeys="true" keyProperty="id">
|
<insert id="insertBmConfig" parameterType="com.bonus.material.basic.domain.BmConfig" useGeneratedKeys="true" keyProperty="id">
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,94 @@
|
||||||
|
<?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="com.bonus.material.task.mapper.TmTaskAuditLogMapper">
|
||||||
|
<resultMap type="com.bonus.material.task.domain.TmTaskAuditLog" id="TmTaskAuditLogResult">
|
||||||
|
<result property="id" column="id" />
|
||||||
|
<result property="taskId" column="task_id" />
|
||||||
|
<result property="taskType" column="task_type" />
|
||||||
|
<result property="roleKey" column="role_key" />
|
||||||
|
<result property="createBy" column="create_by" />
|
||||||
|
<result property="createTime" column="create_time" />
|
||||||
|
<result property="updateBy" column="update_by" />
|
||||||
|
<result property="updateTime" column="update_time" />
|
||||||
|
<result property="remark" column="remark" />
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<sql id="selectTmTaskAuditLogVo">
|
||||||
|
select id, task_id, task_type, role_key, create_by, create_time, update_by, update_time, remark from tm_task_audit_log
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<select id="selectTmTaskAuditLogList" parameterType="com.bonus.material.task.domain.TmTaskAuditLog" resultMap="TmTaskAuditLogResult">
|
||||||
|
<include refid="selectTmTaskAuditLogVo"/>
|
||||||
|
<where>
|
||||||
|
<if test="taskId != null "> and task_id = #{taskId}</if>
|
||||||
|
<if test="taskType != null "> and task_type = #{taskType}</if>
|
||||||
|
<if test="roleKey != null and roleKey != ''"> and role_key = #{roleKey}</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectTmTaskAuditRoleKeyList" parameterType="com.bonus.material.task.domain.TmTaskAuditLog" resultType="java.lang.String">
|
||||||
|
select role_key
|
||||||
|
from tm_task_audit_log
|
||||||
|
<where>
|
||||||
|
<if test="taskId != null "> and task_id = #{taskId}</if>
|
||||||
|
<if test="taskType != null "> and task_type = #{taskType}</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectTmTaskAuditLogById" parameterType="Long" resultMap="TmTaskAuditLogResult">
|
||||||
|
<include refid="selectTmTaskAuditLogVo"/>
|
||||||
|
where id = #{id}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<insert id="insertTmTaskAuditLog" parameterType="com.bonus.material.task.domain.TmTaskAuditLog" useGeneratedKeys="true" keyProperty="id">
|
||||||
|
insert into tm_task_audit_log
|
||||||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="taskId != null">task_id,</if>
|
||||||
|
<if test="taskType != null">task_type,</if>
|
||||||
|
<if test="roleKey != null">role_key,</if>
|
||||||
|
<if test="createBy != null">create_by,</if>
|
||||||
|
<if test="createTime != null">create_time,</if>
|
||||||
|
<if test="updateBy != null">update_by,</if>
|
||||||
|
<if test="updateTime != null">update_time,</if>
|
||||||
|
<if test="remark != null">remark,</if>
|
||||||
|
</trim>
|
||||||
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="taskId != null">#{taskId},</if>
|
||||||
|
<if test="taskType != null">#{taskType},</if>
|
||||||
|
<if test="roleKey != null">#{roleKey},</if>
|
||||||
|
<if test="createBy != null">#{createBy},</if>
|
||||||
|
<if test="createTime != null">#{createTime},</if>
|
||||||
|
<if test="updateBy != null">#{updateBy},</if>
|
||||||
|
<if test="updateTime != null">#{updateTime},</if>
|
||||||
|
<if test="remark != null">#{remark},</if>
|
||||||
|
</trim>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<update id="updateTmTaskAuditLog" parameterType="com.bonus.material.task.domain.TmTaskAuditLog">
|
||||||
|
update tm_task_audit_log
|
||||||
|
<trim prefix="SET" suffixOverrides=",">
|
||||||
|
<if test="taskId != null">task_id = #{taskId},</if>
|
||||||
|
<if test="taskType != null">task_type = #{taskType},</if>
|
||||||
|
<if test="roleKey != null">role_key = #{roleKey},</if>
|
||||||
|
<if test="createBy != null">create_by = #{createBy},</if>
|
||||||
|
<if test="createTime != null">create_time = #{createTime},</if>
|
||||||
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||||
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||||
|
<if test="remark != null">remark = #{remark},</if>
|
||||||
|
</trim>
|
||||||
|
where id = #{id}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<delete id="deleteTmTaskAuditLogById" parameterType="Long">
|
||||||
|
delete from tm_task_audit_log where id = #{id}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<delete id="deleteTmTaskAuditLogsByIds" parameterType="String">
|
||||||
|
delete from tm_task_audit_log where id in
|
||||||
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
</delete>
|
||||||
|
</mapper>
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
//package com.bonus.material.common.utils;
|
||||||
|
//
|
||||||
|
//import com.bonus.material.task.domain.TmTaskAuditResult;
|
||||||
|
//import org.junit.Test;
|
||||||
|
//import static org.hibernate.validator.internal.util.Contracts.assertNotNull;
|
||||||
|
//
|
||||||
|
//public class AuditToolTest {
|
||||||
|
//
|
||||||
|
// @Test
|
||||||
|
// public void testGetDatesBefore1(){
|
||||||
|
// TmTaskAuditResult result = AuditTool.getAuditResult(1L,1L);
|
||||||
|
// assertNotNull(result);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//}
|
||||||
|
|
@ -0,0 +1,47 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#jar_version="24.10.0-SNAPSHOT"
|
||||||
|
|
||||||
|
export deploy_path=/opt/webapps/bonus-material
|
||||||
|
#export app_workspace=/opt/builds/releases/Bonus-Cloud/${jar_version}
|
||||||
|
#export biz_workspace=/opt/install/jenkins_home/workspace/Bonus-Cloud-Material
|
||||||
|
|
||||||
|
#cp -f ${biz_workspace}/"bonus-modules/bonus-material/target/bonus-material.jar" $deploy_path
|
||||||
|
#echo "copied ${app_workspace}/${source_jar} to $deploy_path"
|
||||||
|
|
||||||
|
# Define an array of JAR files to run
|
||||||
|
jars=("bonus-material.jar --spring.config.location=file:material_bootstrap.yml")
|
||||||
|
|
||||||
|
# 遍历数组并检查每个JAR文件的进程
|
||||||
|
for jar_with_args in "${jars[@]}"; do
|
||||||
|
# 提取JAR文件名(不包括参数)
|
||||||
|
jar=$(echo $jar_with_args | awk '{print $1}')
|
||||||
|
|
||||||
|
# 检查进程是否启动
|
||||||
|
echo "原应用程序1 $jar "
|
||||||
|
pids=$(pgrep -f $jar || true)
|
||||||
|
echo "原应用程序2 $jar "
|
||||||
|
if [ -n "$pids" ]; then
|
||||||
|
echo "$jar is running with PID(s): $pids"
|
||||||
|
# 杀死进程
|
||||||
|
for pid in $pids; do
|
||||||
|
kill -9 $pid
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
echo "Process $pid for $jar killed successfully"
|
||||||
|
else
|
||||||
|
echo "Failed to kill process $pid for $jar"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
else
|
||||||
|
echo "$jar is not running"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
cd $deploy_path || { echo "Failed to change directory to $deploy_path"; exit 1; }
|
||||||
|
# Iterate over the JAR files array
|
||||||
|
for jar in "${jars[@]}"; do
|
||||||
|
echo "Starting $jar"
|
||||||
|
nohup /usr/local/jdk1.8.0/bin/java -jar $jar >/dev/null 2>&1 &
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "All JARs have been run successfully."
|
||||||
|
|
||||||
Loading…
Reference in New Issue