@ -1,15 +1,11 @@
package com.ruoyi.purchase.service.impl ;
import com.github.pagehelper.Page ;
import com.ruoyi.common.core.domain.entity.SysUser ;
import com.ruoyi.common.core.page.PageDomain ;
import com.ruoyi.common.core.page.TableSupport ;
import com.ruoyi.common.core.redis.RedisCache ;
import com.ruoyi.common.core.text.Convert ;
import com.ruoyi.common.service.ICommonService ;
import com.ruoyi.common.utils.DateUtils ;
import com.ruoyi.common.utils.ShiroUtils ;
import com.ruoyi.common.utils.StringUtils ;
import com.ruoyi.process.general.service.IProcessService ;
import com.ruoyi.process.todoitem.mapper.BizTodoItemMapper ;
import com.ruoyi.purchase.domain.PurchaseOrder ;
@ -30,10 +26,7 @@ import com.ruoyi.warehouse.mapper.WarehouseStorageOrderDetailMapper;
import com.ruoyi.warehouse.mapper.WarehouseStorageOrderMapper ;
import lombok.extern.slf4j.Slf4j ;
import org.activiti.engine.TaskService ;
import org.activiti.engine.impl.persistence.entity.TaskEntityImpl ;
import org.activiti.engine.runtime.ProcessInstance ;
import org.activiti.engine.task.Task ;
import org.springframework.beans.BeanUtils ;
import org.springframework.beans.factory.annotation.Autowired ;
import org.springframework.stereotype.Service ;
import org.springframework.transaction.annotation.Transactional ;
@ -46,6 +39,8 @@ import java.util.Map;
import java.util.Set ;
import java.util.stream.Collectors ;
import static com.github.pagehelper.page.PageMethod.startPage ;
/ * *
* 采购订单Service业务层处理
*
@ -104,30 +99,25 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService
* @return 采购订单
* /
@Override
public PurchaseOrderVo selectPurchaseOrderById ( Long purchaseOrderId )
public PurchaseOrder selectPurchaseOrderById ( Long purchaseOrderId )
{
PurchaseOrderVo purchaseOrderVo = purchaseOrderMapper . selectPurchaseOrderById ( purchaseOrderId ) ;
SysUser sysUser = userMapper . selectUserByLoginName ( purchaseOrderVo . getApplyUser ( ) ) ;
if ( sysUser ! = null ) {
purchaseOrderVo . setApplyUserName ( sysUser . getUserName ( ) ) ;
}
return purchaseOrderVo ;
// SysUser sysUser = userMapper.selectUserByLoginName(purchaseOrderVo.getApplyUser());
// if (sysUser != null) {
// purchaseOrderVo.setApplyUserName(sysUser.getUserName());
// }
return purchaseOrderMapper . selectPurchaseOrderById ( purchaseOrderId ) ;
}
/ * *
* 查询采购订单列表
*
* @param purchaseOrderVo 采购订单
* @param purchaseOrder 采购订单
* @return 采购订单
* /
@Override
public List < PurchaseOrderVo > selectPurchaseOrderList ( PurchaseOrderVo purchaseOrderVo )
public List < PurchaseOrder > selectPurchaseOrderList ( PurchaseOrder purchaseOrder )
{
// PageHelper 仅对第一个 List 分页
List < PurchaseOrderVo > list = purchaseOrderMapper . selectPurchaseOrderList ( purchaseOrderVo ) ;
return list ;
return purchaseOrderMapper . selectPurchaseOrderList ( purchaseOrder ) ;
}
/ * *
@ -167,32 +157,27 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService
if ( planCode ! = null ) {
PurchaseOrderChild material = new PurchaseOrderChild ( ) ;
child . setPurchaseOrderCode ( purchaseOrder . getPurchaseOrderCode ( ) ) ;
// 累加物料数量和金额
//获取物料供应商采购价格
BigDecimal suplierMaterialNoRmb = child . getMaterialNoRmb ( ) ;
// 获取物料供应商采购价格
BigDecimal suplierMaterialRmb = child . getMaterialRmb ( ) ;
//获取物料供应商不含税采购价格
BigDecimal suplierMaterialNoRmb = child . getMaterialRealNoRmb ( ) ;
// 获取物料供应商含税采购价格
BigDecimal suplierMaterialRmb = child . getMaterialRealRmb ( ) ;
// 获取物料数量
Long suplierMaterialNum = child . getMaterialNum ( ) ;
if ( suplierMaterialNum = = null ) { suplierMaterialNum = 0L ; }
if ( suplierMaterialRmb = = null ) { suplierMaterialRmb = BigDecimal . ZERO ; }
if ( suplierMaterialNoRmb = = null ) { suplierMaterialNoRmb = BigDecimal . ZERO ; }
// 累加物料数量
materialNum + = suplierMaterialNum ;
// 累加不含税物料价格
materialNoRmb = materialNoRmb . add ( suplierMaterialNoRmb ) ;
// 累加含税物料价格
materialRmb = materialRmb . add ( suplierMaterialRmb ) ;
// 计算不含税物料总价
if ( suplierMaterialNoRmb = = null ) { suplierMaterialNoRmb = BigDecimal . ZERO ; }
if ( suplierMaterialRmb = = null ) { suplierMaterialRmb = BigDecimal . ZERO ; }
if ( suplierMaterialNum = = null ) { suplierMaterialNum = 0L ; }
//获取供应商不含税价格合计 = 物料数量 * 供应商采购不含税价格
BigDecimal suplierMaterialNoRmbSumLocal = suplierMaterialNoRmb . multiply ( BigDecimal . valueOf ( suplierMaterialNum ) ) ;
// 计算 物料含税总 价
//获取供应商含税价格合计 = 物料数量 * 供应商采购含税价格
BigDecimal suplierMaterialRmbSumLocal = suplierMaterialRmb . multiply ( BigDecimal . valueOf ( suplierMaterialNum ) ) ;
// 累加物料数量
materialNum + = suplierMaterialNum ;
// 累加物料总价
materialNoRmbSum = materialNoRmbSum . add ( suplierMaterialNoRmbSumLocal ) ;
// 累加物料含税总价
materialRmbSum = materialRmbSum . add ( suplierMaterialRmbSumLocal ) ;
// 设置采购报价单编号和供应商信息到QuoteChild
material . setPurchaseQuote Code ( purchaseOrder . getPurchaseOrderCode ( ) ) ;
material . setPurchaseOrder Code ( purchaseOrder . getPurchaseOrderCode ( ) ) ;
material . setSupplierCode ( child . getSupplierCode ( ) ) ;
material . setMaterialUnit ( child . getMaterialUnit ( ) ) ;
material . setWarehouseDept ( child . getWarehouseDept ( ) ) ;
@ -203,23 +188,26 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService
material . setMaterialDescribe ( child . getMaterialDescribe ( ) ) ;
material . setMaterialPhotoUrl ( child . getMaterialPhotoUrl ( ) ) ;
material . setMaterialProcessMethod ( child . getMaterialProcessMethod ( ) ) ;
material . setWarehouseDept ( child . getWarehouseDept ( ) ) ;
//计划采购数
material . setMaterialNum ( child . getMaterialNum ( ) ) ;
material . setMaterialNoRmb ( child . getMaterialNoRmb ( ) ) ;
material . setMaterialRmb ( child . getMaterialRmb ( ) ) ;
material . setMaterialNum ( child . getMaterialNum ( ) ) ;
material . setMaterialNoRmbSum ( child . getMaterialNoRmbSum ( ) ) ;
material . setMaterialRmbSum ( child . getMaterialRmbSum ( ) ) ;
//实际采购数
material . setMaterialRealNum ( child . getMaterialRealNum ( ) ) ;
material . setMaterialRealNoRmb ( child . getMaterialRealNoRmb ( ) ) ;
material . setMaterialRealRmb ( child . getMaterialRealRmb ( ) ) ;
material . setMaterialRealRmbSum ( child . getMaterialRealRmbSum ( ) ) ;
material . setMaterialRealNo RmbSum ( child . getMaterialRealNoRmbSum ( ) ) ;
material . setMaterialNoRmbSum ( child . getMaterialNoRmbSum ( ) ) ;
material . setCorrelationCode ( correlationCode ) ;
material . setPurchasePlanCode ( p lanCode) ;
//实际采购单价合计
material . setMaterialRealRmbSum ( suplierMaterialRmbSumLocal ) ;
material . setMaterialReal NoRmbSum ( suplierMaterialNoRmbSumLocal ) ;
material . setCorrelationCode ( child . getC orrelationCode ( ) ) ;
material . setPurchasePlanCode ( child . getPurchaseP lanCode( ) ) ;
material . setPurchaseQuoteCode ( child . getPurchaseQuoteCode ( ) ) ;
//收货状态,0:未收货,1:已收货 收款状态:0:待付款,1:已付款
material . setEceiptStatus ( "0" ) ;
material . setPaymentStatus ( "0" ) ;
material . setDelFlag ( "0" ) ;
// 执行子表插入操作
purchaseOrderChildService . insertPurchaseOrderChild ( child ) ;
PurchasePlan plan = new PurchasePlan ( ) ;
@ -228,31 +216,26 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService
int result = purchasePlanService . updatePurchasePlan ( plan ) ;
}
}
child . setMaterialNoRmb ( BigDecimal . ZERO ) ;
}
else if ( ( child . getCorrelationCode ( ) . contains ( "," ) = = false )
else if ( ( ! child . getCorrelationCode ( ) . contains ( "," ) )
& & child . getPurchasePlanCode ( ) ! = null ) {
PurchaseOrderChild material = new PurchaseOrderChild ( ) ;
child . setPurchaseOrderCode ( purchaseOrder . getPurchaseOrderCode ( ) ) ;
//获取物料供应商采购价格
BigDecimal suplierMaterialNoRmb = child . getMaterialNoRmb ( ) ;
// 获取物料供应商采购价格
BigDecimal suplierMaterialRmb = child . getMaterialRmb ( ) ;
//获取物料供应商不含税 采购价格
BigDecimal suplierMaterialNoRmb = child . getMaterialReal NoRmb ( ) ;
// 获取物料供应商含税 采购价格
BigDecimal suplierMaterialRmb = child . getMaterialRealR mb ( ) ;
// 获取物料数量
Long suplierMaterialNum = child . getMaterialNum ( ) ;
// 累加物料数量
materialNum + = suplierMaterialNum ;
if ( suplierMaterialNoRmb = = null ) { suplierMaterialNoRmb = BigDecimal . ZERO ; }
if ( suplierMaterialRmb = = null ) { suplierMaterialRmb = BigDecimal . ZERO ; }
if ( suplierMaterialNum = = null ) { suplierMaterialNum = 0L ; }
// 累加不含税物料价格
materialNoRmb = materialNoRmb . add ( suplierMaterialNoRmb ) ;
// 累加含税物料价格
materialRmb = materialRmb . add ( suplierMaterialRmb ) ;
// 计算不含税物料总价
//获取供应商不含税价格合计 = 物料数量 * 供应商采购不含税价格
BigDecimal suplierMaterialNoRmbSumLocal = suplierMaterialNoRmb . multiply ( BigDecimal . valueOf ( suplierMaterialNum ) ) ;
// 计算 物料含税总 价
//获取供应商含税价格合计 = 物料数量 * 供应商采购含税价格
BigDecimal suplierMaterialRmbSumLocal = suplierMaterialRmb . multiply ( BigDecimal . valueOf ( suplierMaterialNum ) ) ;
// 累加物料数量
materialNum + = suplierMaterialNum ;
// 累加物料总价
materialNoRmbSum = materialNoRmbSum . add ( suplierMaterialNoRmbSumLocal ) ;
// 累加物料含税总价
@ -269,23 +252,26 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService
material . setMaterialDescribe ( child . getMaterialDescribe ( ) ) ;
material . setMaterialPhotoUrl ( child . getMaterialPhotoUrl ( ) ) ;
material . setMaterialProcessMethod ( child . getMaterialProcessMethod ( ) ) ;
material . setWarehouseDept ( child . getWarehouseDept ( ) ) ;
//计划采购数
material . setMaterialNum ( child . getMaterialNum ( ) ) ;
material . setMaterialNoRmb ( child . getMaterialNoRmb ( ) ) ;
material . setMaterialRmb ( child . getMaterialRmb ( ) ) ;
material . setMaterialNum ( child . getMaterialNum ( ) ) ;
material . setMaterialNoRmbSum ( child . getMaterialNoRmbSum ( ) ) ;
material . setMaterialRmbSum ( child . getMaterialRmbSum ( ) ) ;
//实际采购数
material . setMaterialRealNum ( child . getMaterialRealNum ( ) ) ;
material . setMaterialRealNoRmb ( child . getMaterialRealNoRmb ( ) ) ;
material . setMaterialRealRmb ( child . getMaterialRealRmb ( ) ) ;
material . setMaterialRealRmbSum ( child . getMaterialRmbSum ( ) ) ;
material . setMaterialRealNo RmbSum ( child . getMaterialRealNoRmbSum ( ) ) ;
material . setMaterialNoRmbSum ( child . getMaterialNoRmbSum ( ) ) ;
//实际采购单价合计
material . setMaterialRealRmbSum ( suplierMaterialRmbSumLocal ) ;
material . setMaterialReal NoRmbSum ( suplierMaterialNoRmbSumLocal ) ;
material . setCorrelationCode ( child . getCorrelationCode ( ) ) ;
material . setPurchasePlanCode ( child . getPurchasePlanCode ( ) ) ;
material . setPurchaseQuoteCode ( child . getPurchaseQuoteCode ( ) ) ;
//收货状态,0:未收货,1:已收货 收款状态:0:待付款,1:已付款
material . setEceiptStatus ( "0" ) ;
material . setPaymentStatus ( "0" ) ;
material . setDelFlag ( "0" ) ;
// 执行子表插入操作
purchaseOrderChildService . insertPurchaseOrderChild ( child ) ;
PurchasePlan plan = new PurchasePlan ( ) ;
@ -297,12 +283,25 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService
}
// 遍历处理采购订单子表
// 设置累加的物料信息到子表
purchaseOrder . setMaterialSum ( Math . toIntExact ( materialNum ) ) ;
// purchaseOrder.setMaterialSum(purchaseOrder.getMaterialSum());
// purchaseOrder.setNoRmbSum(purchaseOrder.getNoRmbSum());
// purchaseOrder.setRmbSum(purchaseOrder.getRmbSum());
// 设置主表的供应商数量
purchaseOrder . setSupplierNum ( purchaseOrder . getSupplierNum ( ) ) ;
purchaseOrder . setNoRmbSum ( materialNoRmbSum ) ;
purchaseOrder . setRmbSum ( materialRmbSum ) ;
// 设置主表的供应商数量
purchaseOrder . setSupplierNum ( supplierNum ) ;
purchaseOrder . setDelFlag ( "0" ) ;
purchaseOrder . setAuditStatus ( "1" ) ;
purchaseOrder . setUseStatus ( "1" ) ;
purchaseOrder . setEceiptStatus ( "0" ) ;
purchaseOrder . setPaymentStatus ( "0" ) ;
purchaseOrder . setPurchaseBuyer ( purchaseOrder . getPurchaseBuyer ( ) ) ;
purchaseOrder . setCreateTime ( DateUtils . getNowDate ( ) ) ;
purchaseOrder . setCreateBy ( ShiroUtils . getLoginName ( ) ) ;
Set < String > amountSet = purchaseOrder . getPurchaseOrderChildList ( ) . stream ( ) . map ( PurchaseOrderChild : : getMaterialCode ) . collect ( Collectors . toSet ( ) ) ;
Integer amount = amountSet . size ( ) ;
purchaseOrder . setMaterialAmount ( amount ) ;
return purchaseOrderMapper . insertPurchaseOrder ( purchaseOrder ) ;
}
@ -358,13 +357,14 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService
* 采购订单创建采购入库通知单
* * /
@Override
@Transactional ( rollbackFor = Exception . class )
@Transactional ( rollbackFor = Runtime Exception. class )
public int addPurchaseOrderStorage ( WarehouseStorageOrder warehouseStorageOrder ) {
WarehouseStorageOrder warehouseStorageOrder1 = new WarehouseStorageOrder ( ) ;
warehouseStorageOrder1 . setRelatedOrderCode ( warehouseStorageOrder . getRelatedOrderCode ( ) ) ;
List < WarehouseStorageOrder > warehouseStorageOrderList = warehouseStorageOrderMapper . selectWarehouseStorageOrderList ( warehouseStorageOrder1 ) ;
List < WarehouseStorageOrderDetail > list = warehouseStorageOrder . getWarehouseStorageOrderDetailList ( ) ;
if ( CollectionUtils . isEmpty ( warehouseStorageOrderList ) ) {
int result = 0 ;
if ( ! CollectionUtils . isEmpty ( list ) ) {
//根据物料入库部门划分入库单,入库单类型:0 仓库,1 采购,生成入库单号
List < WarehouseStorageOrderDetail > list1 = list . stream ( ) . filter ( e - > e . getMaterialDeptType ( ) . equals ( "0" ) ) . collect ( Collectors . toList ( ) ) ;
List < WarehouseStorageOrderDetail > list2 = list . stream ( ) . filter ( e - > e . getMaterialDeptType ( ) . equals ( "1" ) ) . collect ( Collectors . toList ( ) ) ;
@ -372,7 +372,7 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService
//WarehouseStorageType 仓库入库类型(0采购入库、1供应商补货、2委内入库、3公司退货、4委外入库、5生产入库),
//setWarehouseOrderType仓库订单类型(0采购订单、1生产订单、2退换货订单、3委外订单),
//WarehouseDeptType 仓库入库部门类型(0仓库,1采购 ),
if ( ! CollectionUtils . isEmpty ( list1 ) ) {
if ( list1 . size ( ) > 0 ) {
//采购入库单,物料入库列表信息读取,放入生成的入库订单号
String warehouseStorageCode = redisCache . generateBillNo ( "RK" ) ;
for ( WarehouseStorageOrderDetail warehouseStorageOrderDetail : list1 ) {
@ -386,10 +386,13 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService
warehouseStorageOrder . setWarehouseStorageCode ( warehouseStorageCode ) ;
warehouseStorageOrder . setWarehouseStorageType ( "0" ) ;
warehouseStorageOrder . setWarehouseDeptType ( "0" ) ;
warehouseStorageOrder . setWarehouseOrderType ( "1" ) ;
warehouseStorageOrder . setWarehouseStorageStatus ( "0" ) ;
warehouseStorageOrderMapper . insertWarehouseStorageOrder ( warehouseStorageOrder ) ;
warehouseStorageOrder . setCreateTime ( DateUtils . getNowDate ( ) ) ;
warehouseStorageOrder . setCreateBy ( ShiroUtils . getLoginName ( ) ) ;
result = warehouseStorageOrderMapper . insertWarehouseStorageOrder ( warehouseStorageOrder ) ;
}
if ( ! CollectionUtils . isEmpty ( list2 ) ) {
if ( list . size ( ) > 0 ) {
String warehouseStorageCode1 = redisCache . generateBillNo ( "RK" ) ;
//仓库入库单
for ( WarehouseStorageOrderDetail warehouseStorageOrderDetail : list2 ) {
@ -402,15 +405,19 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService
//入库代表为仓库部分的入库单
warehouseStorageOrder . setWarehouseStorageCode ( warehouseStorageCode1 ) ;
warehouseStorageOrder . setWarehouseStorageStatus ( "0" ) ;
warehouseStorageOrder . setWarehouseQualityStatus ( "0" ) ;
warehouseStorageOrder . setWarehouseStorageType ( "1" ) ;
warehouseStorageOrder . setWarehouseOrderType ( "0" ) ;
warehouseStorageOrder . setWarehouseDeptType ( "1" ) ;
warehouseStorageOrder . setCreateTime ( DateUtils . getNowDate ( ) ) ;
warehouseStorageOrder . setCreateBy ( ShiroUtils . getLoginName ( ) ) ;
warehouseStorageOrder . setWarehouseStorageOrderDetailList ( list2 ) ;
warehouseStorageOrderMapper . insertWarehouseStorageOrder ( warehouseStorageOrder ) ;
result = warehouseStorageOrderMapper . insertWarehouseStorageOrder ( warehouseStorageOrder ) ;
}
}
return 0 ;
return result ;
}
@Override
@Transactional ( rollbackFor = Exception . class )
@ -437,60 +444,70 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService
purchaseOrderMapper . updatePurchaseOrder ( purchaseOrder ) ;
return processInstance ;
}
@Override
@Transactional ( rollbackFor = Exception . class )
public ProcessInstance cancelPurchaseOrderById ( Long id ) {
PurchaseOrderVo purchaseOrderVo = purchaseOrderMapper . selectPurchaseOrderById ( id ) ;
// 审核状态-待审核
purchaseOrderVo . setAuditStatus ( "0" ) ;
SysUser user = ShiroUtils . getSysUser ( ) ;
// 启动流程
String applyTitle = user . getUserName ( ) + "发起了物料信息作废审批-" + DateUtils . dateTimeNow ( ) ;
String instanceType = "cancel" ;
PurchaseOrder purchaseOrder = new PurchaseOrder ( ) ;
BeanUtils . copyProperties ( purchaseOrderVo , purchaseOrder ) ;
ProcessInstance processInstance = startProcessInstance ( applyTitle , instanceType , purchaseOrder , user ) ;
String processInstanceId = processInstance . getProcessInstanceId ( ) ;
// 作废实例id
purchaseOrder . setCancelInstanceId ( processInstanceId ) ;
// 存在提交完就流程结束的情况
boolean processIsFinish = processService . judgeProcessIsFinish ( processInstanceId ) ;
if ( processIsFinish ) {
// 审核状态-审核通过
purchaseOrder . setAuditStatus ( "1" ) ;
// 使用状态-已作废
purchaseOrder . setUseStatus ( "2" ) ;
}
purchaseOrderMapper . updatePurchaseOrder ( purchaseOrder ) ;
return processInstance ;
return null ;
}
@Override
public ProcessInstance restorePurchaseOrderById ( Long id ) {
PurchaseOrderVo purchaseOrderVo = purchaseOrderMapper . selectPurchaseOrderById ( id ) ;
// 审核状态-待审核
purchaseOrderVo . setAuditStatus ( "0" ) ;
SysUser user = ShiroUtils . getSysUser ( ) ;
// 启动流程
String applyTitle = user . getUserName ( ) + "发起了物料信息恢复审批-" + DateUtils . dateTimeNow ( ) ;
String instanceType = "restore" ;
PurchaseOrder purchaseOrder = new PurchaseOrder ( ) ;
BeanUtils . copyProperties ( purchaseOrderVo , purchaseOrder ) ;
ProcessInstance processInstance = startProcessInstance ( applyTitle , instanceType , purchaseOrder , user ) ;
String processInstanceId = processInstance . getProcessInstanceId ( ) ;
// 恢复实例id
purchaseOrder . setRestoreInstanceId ( processInstanceId ) ;
// 存在提交完就流程结束的情况
boolean processIsFinish = processService . judgeProcessIsFinish ( processInstanceId ) ;
if ( processIsFinish ) {
// 审核状态-审核通过
purchaseOrder . setAuditStatus ( "1" ) ;
// 使用状态-是
purchaseOrder . setUseStatus ( "1" ) ;
}
purchaseOrderMapper . updatePurchaseOrder ( purchaseOrder ) ;
return processInstance ;
return null ;
}
// @Override
// @Transactional(rollbackFor = Exception.class)
// public ProcessInstance cancelPurchaseOrderById(Long id) {
// PurchaseOrderVo purchaseOrderVo = purchaseOrderMapper.selectPurchaseOrderById(id);
// // 审核状态-待审核
// purchaseOrderVo.setAuditStatus("0");
// SysUser user = ShiroUtils.getSysUser();
// // 启动流程
// String applyTitle = user.getUserName()+"发起了物料信息作废审批-"+DateUtils.dateTimeNow();
// String instanceType = "cancel";
// PurchaseOrder purchaseOrder = new PurchaseOrder();
// BeanUtils.copyProperties(purchaseOrderVo,purchaseOrder);
// ProcessInstance processInstance = startProcessInstance(applyTitle,instanceType,purchaseOrder, user);
// String processInstanceId = processInstance.getProcessInstanceId();
// // 作废实例id
// purchaseOrder.setCancelInstanceId(processInstanceId);
// // 存在提交完就流程结束的情况
// boolean processIsFinish = processService.judgeProcessIsFinish(processInstanceId);
// if(processIsFinish){
// // 审核状态-审核通过
// purchaseOrder.setAuditStatus("1");
// // 使用状态-已作废
// purchaseOrder.setUseStatus("2");
// }
// purchaseOrderMapper.updatePurchaseOrder(purchaseOrder);
// return processInstance;
// }
// @Override
// public ProcessInstance restorePurchaseOrderById(Long id) {
// PurchaseOrderVo purchaseOrderVo = purchaseOrderMapper.selectPurchaseOrderById(id);
// // 审核状态-待审核
// purchaseOrderVo.setAuditStatus("0");
// SysUser user = ShiroUtils.getSysUser();
// // 启动流程
// String applyTitle = user.getUserName()+"发起了物料信息恢复审批-"+DateUtils.dateTimeNow();
// String instanceType = "restore";
// PurchaseOrder purchaseOrder = new PurchaseOrder();
// BeanUtils.copyProperties(purchaseOrderVo,purchaseOrder);
// ProcessInstance processInstance = startProcessInstance(applyTitle,instanceType,purchaseOrder, user);
// String processInstanceId = processInstance.getProcessInstanceId();
// // 恢复实例id
// purchaseOrder.setRestoreInstanceId(processInstanceId);
// // 存在提交完就流程结束的情况
// boolean processIsFinish = processService.judgeProcessIsFinish(processInstanceId);
// if(processIsFinish){
// // 审核状态-审核通过
// purchaseOrder.setAuditStatus("1");
// // 使用状态-是
// purchaseOrder.setUseStatus("1");
// }
// purchaseOrderMapper.updatePurchaseOrder(purchaseOrder);
// return processInstance;
// }
private ProcessInstance startProcessInstance ( String applyTitle , String instanceType , PurchaseOrder purchaseOrder , SysUser user ) {
Long materialId = purchaseOrder . getPurchaseOrderId ( ) ;
String businessKey = materialId . toString ( ) ; // 实体类 ID,作为流程的业务 key