|
@@ -2,7 +2,6 @@ package com.jsh.erp.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import com.jsh.erp.constants.BusinessConstants;
|
|
|
import com.jsh.erp.constants.ExceptionConstants;
|
|
|
import com.jsh.erp.datasource.dto.AuditDTO;
|
|
|
import com.jsh.erp.datasource.dto.AuditQueryDTO;
|
|
@@ -18,7 +17,6 @@ import com.jsh.erp.datasource.vo.AuditNodeVo;
|
|
|
import com.jsh.erp.datasource.vo.AuditVo;
|
|
|
import com.jsh.erp.exception.BusinessRunTimeException;
|
|
|
import com.jsh.erp.query.LambdaQueryWrapperX;
|
|
|
-import com.jsh.erp.query.QueryWrapperX;
|
|
|
import com.jsh.erp.service.*;
|
|
|
import com.jsh.erp.utils.PageUtils;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
@@ -46,8 +44,6 @@ public class AuditServiceImpl extends ServiceImpl<AuditMapper, Audit> implements
|
|
|
|
|
|
private final DepotHeadService depotHeadService;
|
|
|
|
|
|
- private final DepotItemService depotItemService;
|
|
|
-
|
|
|
private final UserService userService;
|
|
|
|
|
|
private final MaterialBatchService materialBatchService;
|
|
@@ -58,7 +54,6 @@ public class AuditServiceImpl extends ServiceImpl<AuditMapper, Audit> implements
|
|
|
@Resource
|
|
|
private MaterialService materialService;
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 根据审核业务单号和类型生成审核实例及节点实例
|
|
|
* @param businessNumber 业务单号
|
|
@@ -67,7 +62,7 @@ public class AuditServiceImpl extends ServiceImpl<AuditMapper, Audit> implements
|
|
|
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
|
|
public boolean generateAuditByItemId(String businessNumber, String type) {
|
|
|
try {
|
|
|
- //获取失败审核
|
|
|
+ //针对重新提交申请,获取失败审核
|
|
|
Audit a = getOne(new LambdaQueryWrapperX<Audit>()
|
|
|
.eq(Audit::getBusinessNumber,businessNumber)
|
|
|
.eq(Audit::getAuditStatus,2)
|
|
@@ -76,7 +71,7 @@ public class AuditServiceImpl extends ServiceImpl<AuditMapper, Audit> implements
|
|
|
//删除审核
|
|
|
update(new UpdateWrapper<Audit>().set("delete_flag",true).eq("id",a.getId()));
|
|
|
}
|
|
|
- //业务id
|
|
|
+ //获取业务id
|
|
|
Long bid = null;
|
|
|
if (type.equals("盘点任务")){
|
|
|
bid = taskStocktakingService.getOne(new LambdaQueryWrapperX<TaskStocktaking>().eq(TaskStocktaking::getNumber,businessNumber)).getId();
|
|
@@ -85,7 +80,7 @@ public class AuditServiceImpl extends ServiceImpl<AuditMapper, Audit> implements
|
|
|
}else {
|
|
|
bid = depotHeadService.getDepotHead(businessNumber).getId();
|
|
|
}
|
|
|
-
|
|
|
+ //获取审核流程
|
|
|
AuditProcess auditProcess = auditProcessService.getOne(new LambdaQueryWrapperX<AuditProcess>()
|
|
|
.eq(AuditProcess::getType, type)
|
|
|
.eq(AuditProcess::getDeleteFlag, false));
|
|
@@ -109,15 +104,8 @@ public class AuditServiceImpl extends ServiceImpl<AuditMapper, Audit> implements
|
|
|
AuditNode auditNode = buildAuditNode(audit.getId(), auditNodeConfig, user);
|
|
|
auditNodeMapper.insert(auditNode);
|
|
|
} else {
|
|
|
- //无审核流程,算审核通过
|
|
|
- if (type.equals("盘点任务")){
|
|
|
- taskStocktakingService.update(new UpdateWrapper<TaskStocktaking>().set("task_status",1).eq("id",bid));
|
|
|
- }else if (type.equals("pda维护商品")){
|
|
|
- materialInputService.update(new UpdateWrapper<MaterialInput>().set("status",1).eq("id",bid));
|
|
|
- }else {
|
|
|
- //处理单据数据
|
|
|
- depotHeadApproved(bid);
|
|
|
- }
|
|
|
+ //无审核流程,直接通过
|
|
|
+ approved(bid,type);
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
log.error("创建审核流程失败", e);
|
|
@@ -143,8 +131,6 @@ public class AuditServiceImpl extends ServiceImpl<AuditMapper, Audit> implements
|
|
|
|
|
|
/**
|
|
|
* 待我审批数量
|
|
|
- *
|
|
|
- * @return
|
|
|
*/
|
|
|
@Override
|
|
|
public Long pendingApprovalCount() {
|
|
@@ -198,7 +184,6 @@ public class AuditServiceImpl extends ServiceImpl<AuditMapper, Audit> implements
|
|
|
@Override
|
|
|
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
|
|
public boolean setStatus(AuditDTO auditDTO) {
|
|
|
-
|
|
|
User user = userService.getCurrentUser();
|
|
|
//获取当前审核节点
|
|
|
AuditNode auditNode = auditNodeMapper.selectOne(new LambdaQueryWrapperX<AuditNode>()
|
|
@@ -222,30 +207,22 @@ public class AuditServiceImpl extends ServiceImpl<AuditMapper, Audit> implements
|
|
|
//无下一节点,审核阶段结束,修改对应审核内容状态
|
|
|
//修改审核状态
|
|
|
this.update(new UpdateWrapper<Audit>().set("audit_status", 1).eq("id", auditDTO.getId()));
|
|
|
- //生成批次信息
|
|
|
Audit audit = auditMapper.selectById(auditDTO.getId());
|
|
|
- Long dhId = audit.getBusinessId();
|
|
|
- if (audit.getType().equals("盘点任务")){
|
|
|
- taskStocktakingService.update(new UpdateWrapper<TaskStocktaking>().set("task_status",1).eq("id",dhId));
|
|
|
- }else if (audit.getType().equals("pda维护商品")){
|
|
|
- materialInputService.update(new UpdateWrapper<MaterialInput>().set("status",1).eq("id",dhId));
|
|
|
- materialInputApproved(dhId);
|
|
|
- }else {
|
|
|
- depotHeadApproved(dhId);
|
|
|
- }
|
|
|
+ approved(audit.getBusinessId(),audit.getType());
|
|
|
}
|
|
|
- } else { //审批未通过
|
|
|
+ } else {
|
|
|
+ //审批未通过
|
|
|
//修改审核状态
|
|
|
this.update(new UpdateWrapper<Audit>().set("audit_status", 2).eq("id", auditDTO.getId()));
|
|
|
//修改单据状态
|
|
|
Audit audit = auditMapper.selectById(auditDTO.getId());
|
|
|
- Long dhId = audit.getBusinessId();
|
|
|
+ Long businessId = audit.getBusinessId();
|
|
|
if (audit.getType().equals("盘点任务")){
|
|
|
- taskStocktakingService.update(new UpdateWrapper<TaskStocktaking>().set("task_status",8).eq("id",dhId));
|
|
|
+ taskStocktakingService.update(new UpdateWrapper<TaskStocktaking>().set("task_status",8).eq("id",businessId));
|
|
|
}else if (audit.getType().equals("pda维护商品")){
|
|
|
- materialInputService.update(new UpdateWrapper<MaterialInput>().set("status",8).eq("id",dhId));
|
|
|
+ materialInputService.update(new UpdateWrapper<MaterialInput>().set("status",8).eq("id",businessId));
|
|
|
}else {
|
|
|
- depotHeadService.update(new UpdateWrapper<DepotHead>().set("status", 8).eq("id", dhId));
|
|
|
+ depotHeadService.update(new UpdateWrapper<DepotHead>().set("status", 8).eq("id", businessId));
|
|
|
}
|
|
|
}
|
|
|
return true;
|
|
@@ -261,7 +238,6 @@ public class AuditServiceImpl extends ServiceImpl<AuditMapper, Audit> implements
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 根据节点配置构建审核节点实例
|
|
|
* @param aid 审核id
|
|
@@ -299,26 +275,20 @@ public class AuditServiceImpl extends ServiceImpl<AuditMapper, Audit> implements
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 单据审核通过 处理批次信息
|
|
|
- * @param id 单据主表id
|
|
|
+ * 审批通过,处理对应业务
|
|
|
+ * @param businessId 业务id
|
|
|
+ * @param type 业务类型
|
|
|
*/
|
|
|
- private void depotHeadApproved(Long id) {
|
|
|
- DepotHead depotHead = depotHeadService.getDepotHead(id);
|
|
|
- depotHeadService.update(new UpdateWrapper<DepotHead>().set("status", 1).eq("id", id));
|
|
|
- List<DepotItem> list = depotItemService.list(new LambdaQueryWrapperX<DepotItem>().eq(DepotItem::getHeaderId, id));
|
|
|
- //处理批次商品信息
|
|
|
- if (BusinessConstants.DEPOTHEAD_TYPE_IN.equals(depotHead.getType())) {
|
|
|
- for (DepotItem depotItem : list) {
|
|
|
- //表单入库,新增批次商品信息
|
|
|
- materialBatchService.generateMaterialBatchByDepotItemId(depotItem, depotHead.getOrganId());
|
|
|
- //更新当前库存
|
|
|
- depotItemService.updateCurrentStock(depotItem);
|
|
|
- }
|
|
|
- } else if (BusinessConstants.DEPOTHEAD_TYPE_OUT.equals(depotHead.getType())) {
|
|
|
- for (DepotItem depotItem : list) {
|
|
|
- //表单出库,修改商品库存
|
|
|
- materialBatchService.handleMaterialBatchByDepotItemId(depotItem.getId());
|
|
|
- }
|
|
|
+ private void approved(Long businessId, String type) {
|
|
|
+ if (type.equals("盘点任务")){
|
|
|
+ taskStocktakingService.update(new UpdateWrapper<TaskStocktaking>().set("task_status",1).eq("id",businessId));
|
|
|
+ }else if (type.equals("pda维护商品")){
|
|
|
+ materialInputService.update(new UpdateWrapper<MaterialInput>().set("status",1).eq("id",businessId));
|
|
|
+ materialInputApproved(businessId);
|
|
|
+ }else {
|
|
|
+ //单据处理
|
|
|
+ depotHeadService.update(new UpdateWrapper<DepotHead>().set("status", 1).eq("id", businessId));
|
|
|
+ materialBatchService.generateMaterialBatchByDepotHeadId(businessId);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -364,20 +334,6 @@ public class AuditServiceImpl extends ServiceImpl<AuditMapper, Audit> implements
|
|
|
initialStockList.add(materialInitialStock);
|
|
|
materialDTO.setStock(initialStockList);
|
|
|
materialService.insertMaterial(materialDTO,null);
|
|
|
- //处理批次商品信息
|
|
|
-// if (BusinessConstants.DEPOTHEAD_TYPE_IN.equals(depotHead.getType())) {
|
|
|
-// for (DepotItem depotItem : list) {
|
|
|
-// //表单入库,新增批次商品信息
|
|
|
-// materialBatchService.generateMaterialBatchByDepotItemId(depotItem, depotHead.getOrganId());
|
|
|
-// //更新当前库存
|
|
|
-// depotItemService.updateCurrentStock(depotItem);
|
|
|
-// }
|
|
|
-// } else if (BusinessConstants.DEPOTHEAD_TYPE_OUT.equals(depotHead.getType())) {
|
|
|
-// for (DepotItem depotItem : list) {
|
|
|
-// //表单出库,修改商品库存
|
|
|
-// materialBatchService.handleMaterialBatchByDepotItemId(depotItem.getId());
|
|
|
-// }
|
|
|
-// }
|
|
|
}
|
|
|
|
|
|
}
|