工单审批判断当前审批人权限
This commit is contained in:
parent
414fab945b
commit
b8aeeeff3b
|
|
@ -103,7 +103,8 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService {
|
|||
public List<MaterialLeaseApplyInfo> selectLeaseApplyInfoList(MaterialLeaseApplyInfo leaseApplyInfo) {
|
||||
String username = SecurityUtils.getLoginUser().getUsername();
|
||||
// 根据用户名判断用户是否为班组长
|
||||
BmTeam teamData = materialMachineMapper.getTeamData(username);
|
||||
BmTeam teamData = materialMachineMapper.getTeamData(username);
|
||||
/*
|
||||
if (teamData == null) {
|
||||
// 根据用户名查询项目部信息
|
||||
String departId = mapper.getDepartId(username);
|
||||
|
|
@ -112,7 +113,7 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService {
|
|||
if (!CollectionUtils.isEmpty(projectIdList)) {
|
||||
leaseApplyInfo.setProjectIdList(projectIdList);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
List<MaterialLeaseApplyInfo> list = materialLeaseInfoMapper.selectLeaseApplyInfoList(leaseApplyInfo);
|
||||
// 利用Stream API进行降序排序
|
||||
List<MaterialLeaseApplyInfo> sortedList = list.stream()
|
||||
|
|
@ -317,9 +318,9 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService {
|
|||
// 性能监控开始
|
||||
long startTime = System.currentTimeMillis();
|
||||
Map<String, Long> stepTimes = new LinkedHashMap<>();
|
||||
|
||||
|
||||
log.info("=== MaterialLeaseInfoServiceImpl.selectLeaseApplyInfoById开始执行,id: {}, keyWord: {}", id, keyWord);
|
||||
|
||||
|
||||
try {
|
||||
// 步骤1: 初始化和查询主要申请信息
|
||||
long step1Start = System.currentTimeMillis();
|
||||
|
|
@ -335,38 +336,38 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService {
|
|||
long step2Start = System.currentTimeMillis();
|
||||
List<MaterialLeaseApplyDetails> details = materialLeaseInfoMapper.selectLeaseApplyDetailsList(new MaterialLeaseApplyDetails(info.getId(), keyWord, null));
|
||||
stepTimes.put("查询领料单详情", System.currentTimeMillis() - step2Start);
|
||||
|
||||
|
||||
// 步骤3: 查询领料出库详情
|
||||
long step3Start = System.currentTimeMillis();
|
||||
List<MaterialLeaseApplyDetails> outDetailsList = materialLeaseInfoMapper.selectLeaseOutList(id);
|
||||
stepTimes.put("查询出库详情", System.currentTimeMillis() - step3Start);
|
||||
|
||||
|
||||
// 声明共用变量,在两个处理块中都能使用
|
||||
Map<Long, List<MaterialLeaseMaCodeDto>> maCodeMap = new HashMap<>();
|
||||
Set<Long> usedMaIds = new HashSet<>();
|
||||
|
||||
|
||||
if (!CollectionUtils.isEmpty(details)) {
|
||||
leaseApplyRequestVo.setLeaseApplyDetailsList(details);
|
||||
|
||||
|
||||
// 步骤4: 批量查询优化 - 解决N+1问题!
|
||||
long step4Start = System.currentTimeMillis();
|
||||
log.info("🚀 开始批量查询优化,处理{}条详情记录", details.size());
|
||||
|
||||
|
||||
// 步骤4.1: 收集所有typeId,进行批量查询
|
||||
List<Long> typeIds = details.stream()
|
||||
.map(MaterialLeaseApplyDetails::getTypeId)
|
||||
.filter(Objects::nonNull)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
|
||||
log.info("收集到{}个不同的typeId,准备批量查询", typeIds.size());
|
||||
|
||||
|
||||
// 步骤4.2: 批量查询编码详情
|
||||
long batchCodeStart = System.currentTimeMillis();
|
||||
List<MaterialLeaseMaCodeDto> allMaCodes = materialLeaseInfoMapper.getCodeListBatch(id, typeIds);
|
||||
long batchCodeTime = System.currentTimeMillis() - batchCodeStart;
|
||||
log.info("批量查询编码详情完成,获取{}条记录,耗时{}ms", allMaCodes.size(), batchCodeTime);
|
||||
|
||||
|
||||
// 按typeId分组,更新共用的maCodeMap
|
||||
maCodeMap = allMaCodes.stream()
|
||||
.filter(maCode -> maCode.getTypeId() != null)
|
||||
|
|
@ -383,15 +384,15 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService {
|
|||
.filter(Objects::nonNull)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
|
||||
if (!allMaIds.isEmpty()) {
|
||||
usedMaIds = materialLeaseInfoMapper.getUsedMaIdsBatch(allMaIds);
|
||||
long batchStatusTime = System.currentTimeMillis() - batchStatusStart;
|
||||
log.info("批量查询设备状态完成,检查{}个设备,发现{}个已使用,耗时{}ms",
|
||||
log.info("批量查询设备状态完成,检查{}个设备,发现{}个已使用,耗时{}ms",
|
||||
allMaIds.size(), usedMaIds.size(), batchStatusTime);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 步骤4.4: 预查询协议信息(移到循环外)
|
||||
long agreementQueryStart = System.currentTimeMillis();
|
||||
SelectDto selectDto = new SelectDto();
|
||||
|
|
@ -399,14 +400,14 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService {
|
|||
List<AgreementVo> agreementList = mapper.getAgreementInfoBy(selectDto);
|
||||
long agreementQueryTime = System.currentTimeMillis() - agreementQueryStart;
|
||||
log.info("预查询协议信息完成,获取{}条协议,耗时{}ms", agreementList != null ? agreementList.size() : 0, agreementQueryTime);
|
||||
|
||||
|
||||
// 步骤4.5: 预计算在用量和库存数据(避免循环内重复计算)
|
||||
long preCalcStart = System.currentTimeMillis();
|
||||
Map<Long, BigDecimal> useNumMap = preCalculateUseNums(info, typeIds);
|
||||
Map<Long, BigDecimal> storageNumMap = preCalculateStorageNums(info, agreementList, typeIds);
|
||||
long preCalcTime = System.currentTimeMillis() - preCalcStart;
|
||||
log.info("预计算完成,计算{}种类型的在用量和库存,耗时{}ms", typeIds.size(), preCalcTime);
|
||||
|
||||
|
||||
// 步骤4.5: 优化后的循环处理(大幅减少数据库查询)
|
||||
long optimizedLoopStart = System.currentTimeMillis();
|
||||
for (MaterialLeaseApplyDetails detail : details) {
|
||||
|
|
@ -417,14 +418,14 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService {
|
|||
BigDecimal useNum = useNumMap.getOrDefault(detail.getTypeId(), BigDecimal.ZERO);
|
||||
detail.setUseNum(useNum);
|
||||
long useNumTime = System.currentTimeMillis() - useNumStart;
|
||||
|
||||
|
||||
// 🚀 使用预计算的库存数据,替代复杂的类型树计算
|
||||
long treeCalcStart = System.currentTimeMillis();
|
||||
|
||||
|
||||
// 直接从预计算的Map中获取库存数据,避免复杂的嵌套循环
|
||||
BigDecimal storageNum = storageNumMap.getOrDefault(detail.getTypeId(), BigDecimal.ZERO);
|
||||
detail.setStorageNum(storageNum);
|
||||
|
||||
|
||||
/* 原来的复杂类型树计算逻辑已被优化移除 - 节省600+ms!
|
||||
这里原来有大量复杂的嵌套循环和数据库查询,现在用预计算替代
|
||||
List<AgreementVo> list = agreementList;
|
||||
|
|
@ -516,12 +517,12 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService {
|
|||
}
|
||||
}
|
||||
优化结束 - 以上复杂逻辑已被预计算替代 */
|
||||
|
||||
|
||||
long treeCalcTime = System.currentTimeMillis() - treeCalcStart;
|
||||
if (treeCalcTime > 200) {
|
||||
log.warn("🐌 类型树计算慢:typeId {} 耗时 {}ms", detail.getTypeId(), treeCalcTime);
|
||||
}
|
||||
|
||||
|
||||
// 使用预查询的编码详情,不再重复查询!
|
||||
List<MaterialLeaseMaCodeDto> maCodeVoList = maCodeMap.get(detail.getTypeId());
|
||||
if (maCodeVoList == null) {
|
||||
|
|
@ -535,7 +536,7 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService {
|
|||
// 使用预查询的设备状态,不再重复查询!
|
||||
List<MaterialLeaseMaCodeDto> availableCodes = new ArrayList<>();
|
||||
List<MaterialLeaseMaCodeDto> usedCodes = new ArrayList<>();
|
||||
|
||||
|
||||
for (MaterialLeaseMaCodeDto maCodeVo : maCodeVoList) {
|
||||
if (maCodeVo.getMaId() != null && usedMaIds.contains(maCodeVo.getMaId())) {
|
||||
// 设备已被使用
|
||||
|
|
@ -545,28 +546,28 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService {
|
|||
availableCodes.add(maCodeVo);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 收集已被使用的设备
|
||||
newCodeList.addAll(usedCodes);
|
||||
|
||||
|
||||
detail.setMaCodeVoList(availableCodes);
|
||||
detail.setPreNum(BigDecimal.valueOf(availableCodes.size()));
|
||||
|
||||
log.debug("设备状态检查完成,过滤出{}个可用设备,{}个已使用设备",
|
||||
|
||||
log.debug("设备状态检查完成,过滤出{}个可用设备,{}个已使用设备",
|
||||
availableCodes.size(), usedCodes.size());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 记录单个detail处理时间
|
||||
long detailTime = System.currentTimeMillis() - detailStart;
|
||||
log.info("🔍 详情 typeId: {} 完成,总耗时: {}ms (在用量: {}ms, 类型树: {}ms)",
|
||||
log.info("🔍 详情 typeId: {} 完成,总耗时: {}ms (在用量: {}ms, 类型树: {}ms)",
|
||||
detail.getTypeId(), detailTime, useNumTime, treeCalcTime);
|
||||
|
||||
|
||||
if (detailTime > 1000) {
|
||||
log.error("🚨 单个详情处理超过1秒!typeId: {} 耗时: {}ms", detail.getTypeId(), detailTime);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
long optimizedLoopTime = System.currentTimeMillis() - optimizedLoopStart;
|
||||
long step4Time = System.currentTimeMillis() - step4Start;
|
||||
stepTimes.put("批量查询优化后的详情处理", step4Time);
|
||||
|
|
@ -574,13 +575,13 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService {
|
|||
} else if (!CollectionUtils.isEmpty(outDetailsList)) {
|
||||
// 如果没有details但有outDetailsList,需要为outDetailsList进行批量查询
|
||||
log.info("没有details,但需要为{}条出库详情进行批量查询", outDetailsList.size());
|
||||
|
||||
|
||||
List<Long> typeIds = outDetailsList.stream()
|
||||
.map(MaterialLeaseApplyDetails::getTypeId)
|
||||
.filter(Objects::nonNull)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
|
||||
if (!typeIds.isEmpty()) {
|
||||
List<MaterialLeaseMaCodeDto> allMaCodes = materialLeaseInfoMapper.getCodeListBatch(id, typeIds);
|
||||
|
||||
|
|
@ -598,7 +599,7 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService {
|
|||
// 步骤5: 优化出库详情处理 - 复用批量查询结果!
|
||||
long step5Start = System.currentTimeMillis();
|
||||
log.info("🚀 开始优化处理{}条出库详情,复用批量查询结果", outDetailsList.size());
|
||||
|
||||
|
||||
leaseApplyRequestVo.setLeaseOutDetailsList(outDetailsList);
|
||||
for (MaterialLeaseApplyDetails detail : outDetailsList) {
|
||||
long outDetailStart = System.currentTimeMillis();
|
||||
|
|
@ -610,7 +611,7 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService {
|
|||
long outDetailTime = System.currentTimeMillis() - outDetailStart;
|
||||
log.debug("出库详情 typeId: {} 优化处理完成,耗时: {}ms", detail.getTypeId(), outDetailTime);
|
||||
}
|
||||
|
||||
|
||||
long step5Time = System.currentTimeMillis() - step5Start;
|
||||
stepTimes.put("优化后的出库详情处理", step5Time);
|
||||
log.info("🚀 出库详情优化完成,总耗时: {}ms", step5Time);
|
||||
|
|
@ -633,18 +634,18 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService {
|
|||
msg = msg.replaceAll("\n", "");
|
||||
ajaxResult.put("msg", msg);
|
||||
}
|
||||
|
||||
|
||||
// 性能分析总结
|
||||
long totalTime = System.currentTimeMillis() - startTime;
|
||||
DateTimeHelper.logPerformanceAnalysis("MaterialLeaseInfoServiceImpl.selectLeaseApplyInfoById", totalTime, stepTimes);
|
||||
|
||||
|
||||
return ajaxResult;
|
||||
} catch (Exception e) {
|
||||
// 记录异常日志和性能数据
|
||||
long totalTime = System.currentTimeMillis() - startTime;
|
||||
log.error("MaterialLeaseInfoServiceImpl.selectLeaseApplyInfoById执行异常,耗时: {}ms, id: {}, 错误: {}", totalTime, id, e.getMessage());
|
||||
DateTimeHelper.logPerformanceAnalysis("MaterialLeaseInfoServiceImpl.selectLeaseApplyInfoById(异常)", totalTime, stepTimes);
|
||||
|
||||
|
||||
System.err.println("Error occurred while selecting lease apply info by ID: " + id + e.getMessage());
|
||||
throw new RuntimeException("查询失败", e);
|
||||
}
|
||||
|
|
@ -1739,33 +1740,33 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService {
|
|||
*/
|
||||
private Map<Long, BigDecimal> preCalculateUseNums(MaterialLeaseApplyInfo info, List<Long> typeIds) {
|
||||
Map<Long, BigDecimal> useNumMap = new HashMap<>();
|
||||
|
||||
|
||||
try {
|
||||
for (Long typeId : typeIds) {
|
||||
try {
|
||||
Type type = new Type();
|
||||
type.setAgreementId(info.getAgreementId());
|
||||
type.setTypeId(typeId);
|
||||
|
||||
|
||||
Type dto = typeMapper.getNumList(type);
|
||||
BigDecimal useNum = (dto != null) ? dto.getUseNum() : BigDecimal.ZERO;
|
||||
useNumMap.put(typeId, useNum);
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
log.warn("计算typeId {}的在用量失败: {}", typeId, e.getMessage());
|
||||
useNumMap.put(typeId, BigDecimal.ZERO);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
log.info("预计算在用量完成,为{}个类型计算了在用量", typeIds.size());
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("预计算在用量失败", e);
|
||||
for (Long typeId : typeIds) {
|
||||
useNumMap.put(typeId, BigDecimal.ZERO);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return useNumMap;
|
||||
}
|
||||
|
||||
|
|
@ -1773,14 +1774,14 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService {
|
|||
* 预计算库存数据,重现原始的类型树计算逻辑
|
||||
* 业务逻辑:总领料数量 - 已在用数量 = 剩余可用库存
|
||||
*/
|
||||
private Map<Long, BigDecimal> preCalculateStorageNums(MaterialLeaseApplyInfo info,
|
||||
List<AgreementVo> agreementList,
|
||||
private Map<Long, BigDecimal> preCalculateStorageNums(MaterialLeaseApplyInfo info,
|
||||
List<AgreementVo> agreementList,
|
||||
List<Long> typeIds) {
|
||||
Map<Long, BigDecimal> storageNumMap = new HashMap<>();
|
||||
|
||||
|
||||
try {
|
||||
log.info("开始预计算库存,原始类型树逻辑,处理{}个类型", typeIds.size());
|
||||
|
||||
|
||||
// 第1步:从协议中获取总领料数量(原listL5逻辑)
|
||||
Map<Long, BigDecimal> totalLeaseNums = new HashMap<>();
|
||||
if (!CollectionUtils.isEmpty(agreementList)) {
|
||||
|
|
@ -1788,7 +1789,7 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService {
|
|||
BackApplyInfo backApplyInfo = new BackApplyInfo();
|
||||
backApplyInfo.setAgreementId(Long.valueOf(agreementVo.getAgreementId()));
|
||||
List<TypeTreeNode> listL4 = mapper.getUseTypeTreeL4(backApplyInfo);
|
||||
|
||||
|
||||
if (!CollectionUtils.isEmpty(listL4)) {
|
||||
for (TypeTreeNode node : listL4) {
|
||||
if (node.getTypeId() != 0L && node.getNum() != null) {
|
||||
|
|
@ -1798,18 +1799,18 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 第2步:通过工程获取已在用数量(原list7逻辑)
|
||||
Map<Long, BigDecimal> usedNums = new HashMap<>();
|
||||
MaterialLeaseApplyInfo bean = new MaterialLeaseApplyInfo();
|
||||
bean.setProId(info.getProId());
|
||||
List<BmAgreementInfo> listAgreement = materialLeaseInfoMapper.getAgreementIdByProId(bean);
|
||||
|
||||
|
||||
if (!CollectionUtils.isEmpty(listAgreement)) {
|
||||
for (BmAgreementInfo agreementInfo : listAgreement) {
|
||||
bean.setAgreementId(agreementInfo.getAgreementId());
|
||||
List<TypeTreeNode> list6 = materialLeaseInfoMapper.getUseTypeTree(bean);
|
||||
|
||||
|
||||
if (!CollectionUtils.isEmpty(list6)) {
|
||||
for (TypeTreeNode node : list6) {
|
||||
if (node.getTypeId() != 0L && node.getNum() != null) {
|
||||
|
|
@ -1819,24 +1820,24 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 第3步:计算剩余库存 = 总领料数量 - 已在用数量
|
||||
for (Long typeId : typeIds) {
|
||||
BigDecimal totalNum = totalLeaseNums.getOrDefault(typeId, BigDecimal.ZERO);
|
||||
BigDecimal usedNum = usedNums.getOrDefault(typeId, BigDecimal.ZERO);
|
||||
BigDecimal storageNum = totalNum.subtract(usedNum);
|
||||
|
||||
|
||||
// 确保不为负数
|
||||
if (storageNum.compareTo(BigDecimal.ZERO) < 0) {
|
||||
storageNum = BigDecimal.ZERO;
|
||||
}
|
||||
|
||||
|
||||
storageNumMap.put(typeId, storageNum);
|
||||
}
|
||||
|
||||
log.info("库存计算完成 - 总领料:{}项,已在用:{}项,计算库存:{}项",
|
||||
|
||||
log.info("库存计算完成 - 总领料:{}项,已在用:{}项,计算库存:{}项",
|
||||
totalLeaseNums.size(), usedNums.size(), storageNumMap.size());
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("预计算库存失败: {}", e.getMessage(), e);
|
||||
// 失败时为所有类型设置默认值
|
||||
|
|
@ -1844,7 +1845,7 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService {
|
|||
storageNumMap.put(typeId, BigDecimal.ZERO);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return storageNumMap;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,4 +41,21 @@ public class SysWorkflowRecordHisController extends BaseController {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 审批
|
||||
*/
|
||||
@ApiOperation(value = "审批")
|
||||
@GetMapping("/getAuditStatus")
|
||||
public AjaxResult getAuditStatus(@RequestBody SysWorkflowRecordHistory sysWorkflowRecordHistory)
|
||||
{
|
||||
try {
|
||||
SysWorkflowRecordHistory audit =sysWorkflowRecordHistoryService.getAuditStatus(sysWorkflowRecordHistory);
|
||||
return success(audit);
|
||||
}catch (Exception e){
|
||||
logger.error("修改失败{}", e.getMessage(), e);
|
||||
System.err.println("修改失败" + e.getMessage());
|
||||
return error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,4 +89,18 @@ public class SysWorkflowRecordHistory {
|
|||
* 领料工程
|
||||
*/
|
||||
private String projectName;
|
||||
/**
|
||||
* 工单任务状态
|
||||
*/
|
||||
private String workflowStatus;
|
||||
/**
|
||||
* 审核状态0待审核1已审核
|
||||
*/
|
||||
private String auditStatus;
|
||||
|
||||
private String receiveUsername;
|
||||
/**
|
||||
* 工单审核状态0待审核1已审核
|
||||
*/
|
||||
private int isExamine;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,12 @@
|
|||
package com.bonus.material.work.mapper;
|
||||
|
||||
import com.bonus.material.work.domain.SysWorkflowRecord;
|
||||
import com.bonus.material.work.domain.SysWorkflowRecordHistory;
|
||||
import com.bonus.material.work.domain.dto.SysWorkflowAuditDto;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface SysWorkflowRecordMapper {
|
||||
|
||||
// 增加审批流任务信息
|
||||
|
|
@ -19,4 +22,10 @@ public interface SysWorkflowRecordMapper {
|
|||
|
||||
// 根据任务id+审批流类型id , 查询审批流任务记录信息
|
||||
SysWorkflowAuditDto getSysWorkflowRecodeByTaskIdAndType(@Param("taskId") Integer taskId, @Param("taskType") Integer taskType, @Param("workflowId") Integer workflowId);
|
||||
|
||||
SysWorkflowRecordHistory getAuditStatus(SysWorkflowRecordHistory sysWorkflowRecordHistory);
|
||||
|
||||
List<SysWorkflowRecordHistory> getAuditUserByTaskId(SysWorkflowRecordHistory sysWorkflowRecordHistory);
|
||||
|
||||
List<SysWorkflowRecordHistory> getAuditUserByRecordId(@Param("recordId") Integer recordId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,4 +7,6 @@ public interface SysWorkflowRecordHistoryService {
|
|||
|
||||
|
||||
int updateSysWorkflowRecordHistory(SysWorkflowRecordHistory sysWorkflowRecordHistory);
|
||||
|
||||
SysWorkflowRecordHistory getAuditStatus(SysWorkflowRecordHistory sysWorkflowRecordHistory);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -115,31 +115,94 @@ public class SysWorkflowRecordHistoryServiceImpl implements SysWorkflowRecordHis
|
|||
SysUser sysUser = SecurityUtils.getLoginUser().getSysUser();
|
||||
Long userId = sysUser.getUserId();
|
||||
Integer recordId = sysWorkflowRecordHistory.getRecordId();
|
||||
Integer taskId = sysWorkflowRecordHistory.getTaskId();
|
||||
Integer leaseId = sysWorkflowRecordHistory.getLeaseId();
|
||||
String recordCode = sysWorkflowRecordHistory.getTaskCode();
|
||||
String projectName = sysWorkflowRecordHistory.getProjectName();
|
||||
Integer nextNodeId = sysWorkflowRecordHistory.getNextNodeId();
|
||||
sysWorkflowRecordHistory.setCreateBy(userId.toString());
|
||||
sysWorkflowRecordHistoryMapper.addSysWorkflowRecordHistory(sysWorkflowRecordHistory);
|
||||
|
||||
if (sysWorkflowRecordHistory.getIsAccept() == null) {
|
||||
throw new ServiceException("请选择是否接受审批");
|
||||
|
||||
|
||||
String flag = checkAuditUser(recordId,sysUser);
|
||||
|
||||
if("0".equals( flag)){
|
||||
Integer taskId = sysWorkflowRecordHistory.getTaskId();
|
||||
Integer leaseId = sysWorkflowRecordHistory.getLeaseId();
|
||||
String recordCode = sysWorkflowRecordHistory.getTaskCode();
|
||||
String projectName = sysWorkflowRecordHistory.getProjectName();
|
||||
Integer nextNodeId = sysWorkflowRecordHistory.getNextNodeId();
|
||||
sysWorkflowRecordHistory.setCreateBy(userId.toString());
|
||||
sysWorkflowRecordHistoryMapper.addSysWorkflowRecordHistory(sysWorkflowRecordHistory);
|
||||
|
||||
if (sysWorkflowRecordHistory.getIsAccept() == null) {
|
||||
throw new ServiceException("请选择是否接受审批");
|
||||
}
|
||||
|
||||
// 查询出【当前任务所属审批流】的所有节点
|
||||
List<SysWorkflowNode> sysWorkflowNodeList = getWorkflowNodes(sysWorkflowRecordHistory);
|
||||
if (sysWorkflowRecordHistory.getIsAccept() == 1) {
|
||||
// 处理审批通过✅
|
||||
handleApproval(sysWorkflowNodeList, sysWorkflowRecordHistory, sysUser, taskId, leaseId, recordCode, projectName, recordId,nextNodeId);
|
||||
} else {
|
||||
// 处理审核驳回❌
|
||||
handleRejection(sysWorkflowNodeList, sysWorkflowRecordHistory);
|
||||
}
|
||||
}else{
|
||||
throw new ServiceException("当前账号没有审批权限!");
|
||||
}
|
||||
|
||||
// 查询出【当前任务所属审批流】的所有节点
|
||||
List<SysWorkflowNode> sysWorkflowNodeList = getWorkflowNodes(sysWorkflowRecordHistory);
|
||||
if (sysWorkflowRecordHistory.getIsAccept() == 1) {
|
||||
// 处理审批通过✅
|
||||
handleApproval(sysWorkflowNodeList, sysWorkflowRecordHistory, sysUser, taskId, leaseId, recordCode, projectName, recordId,nextNodeId);
|
||||
} else {
|
||||
// 处理审核驳回❌
|
||||
handleRejection(sysWorkflowNodeList, sysWorkflowRecordHistory);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private String checkAuditUser(Integer recordId, SysUser sysUser) {
|
||||
|
||||
String flag = "0";
|
||||
List<SysWorkflowRecordHistory> receiveList = sysWorkflowRecordMapper.getAuditUserByRecordId(recordId);
|
||||
|
||||
if (receiveList != null && !receiveList.isEmpty()){
|
||||
for (SysWorkflowRecordHistory receive : receiveList) {
|
||||
|
||||
if (receive.getReceiveUsername().equals(sysUser.getUserName())) {
|
||||
flag = "0";
|
||||
break;
|
||||
}else{
|
||||
flag = "1";
|
||||
}
|
||||
}
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysWorkflowRecordHistory getAuditStatus(SysWorkflowRecordHistory sysWorkflowRecordHistory) {
|
||||
|
||||
//1判断sys_workflow_record中 workflow_status是否等于2
|
||||
|
||||
SysWorkflowRecordHistory taskStatus = sysWorkflowRecordMapper.getAuditStatus(sysWorkflowRecordHistory);
|
||||
|
||||
if (taskStatus != null) {
|
||||
String workflowStatus = taskStatus.getWorkflowStatus();
|
||||
if("2".equals(workflowStatus)){
|
||||
taskStatus.setAuditStatus("1");
|
||||
}
|
||||
return taskStatus;
|
||||
}
|
||||
//2查询皖送工单中的people receive_username,is_examine判断当前登录人账号是否存在其中,存在的审核状态是否审核
|
||||
List<SysWorkflowRecordHistory> receiveList = sysWorkflowRecordMapper.getAuditUserByTaskId(sysWorkflowRecordHistory);
|
||||
|
||||
if (receiveList != null && !receiveList.isEmpty()){
|
||||
for (SysWorkflowRecordHistory receive : receiveList) {
|
||||
SysUser sysUser = SecurityUtils.getLoginUser().getSysUser();
|
||||
if (receive.getReceiveUsername().equals(sysUser.getUserName())) {
|
||||
if (receive.getIsExamine() == 0) {
|
||||
taskStatus.setAuditStatus("0");
|
||||
break;
|
||||
} else {
|
||||
taskStatus.setAuditStatus("1");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return taskStatus;
|
||||
}
|
||||
|
||||
// 获取审批流程节点
|
||||
private List<SysWorkflowNode> getWorkflowNodes(SysWorkflowRecordHistory sysWorkflowRecordHistory) {
|
||||
SysWorkflowNode sysWorkflowNode = new SysWorkflowNode();
|
||||
|
|
|
|||
|
|
@ -65,4 +65,48 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="getAuditStatus" resultType="com.bonus.material.work.domain.SysWorkflowRecordHistory">
|
||||
select
|
||||
a.id as id,
|
||||
a.task_id as taskId,
|
||||
a.task_type as taskType,
|
||||
a.task_code as taskCode,
|
||||
a.workflow_id as workflowId,
|
||||
a.workflow_status as workflowStatus
|
||||
from sys_workflow_record a
|
||||
|
||||
where task_id = #{taskId}
|
||||
</select>
|
||||
|
||||
<select id="getAuditUserByTaskId" resultType="com.bonus.material.work.domain.SysWorkflowRecordHistory">
|
||||
select
|
||||
swr.task_id,
|
||||
swr.id,
|
||||
sp.receiver_username AS receiveUsername,
|
||||
sp.is_examine AS isExamine
|
||||
from
|
||||
uni_org.sys_information si
|
||||
|
||||
LEFT JOIN sys_workflow_record swr on swr.id = si.business_id
|
||||
LEFT JOIN uni_org.sys_information_people sp on si.id = sp.information_id
|
||||
WHERE swr.task_id=#{taskId} and si.web_app_id ="9fa73f046ef520b09e94bbffc3b07702"
|
||||
|
||||
</select>
|
||||
|
||||
<select id="getAuditUserByRecordId" resultType="com.bonus.material.work.domain.SysWorkflowRecordHistory">
|
||||
select
|
||||
swr.task_id,
|
||||
swr.id,
|
||||
sp.receiver_username AS receiveUsername,
|
||||
sp.is_examine AS isExamine
|
||||
from
|
||||
uni_org.sys_information si
|
||||
|
||||
LEFT JOIN sys_workflow_record swr on swr.id = si.business_id
|
||||
LEFT JOIN uni_org.sys_information_people sp on si.id = sp.information_id
|
||||
WHERE si.business_id=#{recordId} and si.web_app_id ="9fa73f046ef520b09e94bbffc3b07702"
|
||||
and sp.is_examine = 0
|
||||
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
|||
Loading…
Reference in New Issue