|
@@ -1,17 +1,24 @@
|
|
package com.yh.saas.plugin.yiliangyiyun.service.impl;
|
|
package com.yh.saas.plugin.yiliangyiyun.service.impl;
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
|
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
|
import com.baomidou.mybatisplus.plugins.Page;
|
|
import com.baomidou.mybatisplus.plugins.Page;
|
|
import com.google.common.collect.Lists;
|
|
import com.google.common.collect.Lists;
|
|
|
|
+import com.winsea.svc.base.workflow.entity.Workflow;
|
|
import com.yh.saas.common.support.util.IdGenerator;
|
|
import com.yh.saas.common.support.util.IdGenerator;
|
|
import com.yh.saas.plugin.yiliangyiyun.constant.StatusEnum;
|
|
import com.yh.saas.plugin.yiliangyiyun.constant.StatusEnum;
|
|
import com.yh.saas.plugin.yiliangyiyun.entity.*;
|
|
import com.yh.saas.plugin.yiliangyiyun.entity.*;
|
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.exception.YException;
|
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.exception.YExceptionEnum;
|
|
import com.yh.saas.plugin.yiliangyiyun.mapper.*;
|
|
import com.yh.saas.plugin.yiliangyiyun.mapper.*;
|
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.service.INewWorkflowService;
|
|
import com.yh.saas.plugin.yiliangyiyun.service.IPurchasePriceService;
|
|
import com.yh.saas.plugin.yiliangyiyun.service.IPurchasePriceService;
|
|
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
@@ -34,6 +41,8 @@ public class PurchasePriceServiceImpl extends ServiceImpl<PurchasePriceMapper, P
|
|
private PurchasePriceDetailPrintMapper purchasePriceDetailPrintMapper;
|
|
private PurchasePriceDetailPrintMapper purchasePriceDetailPrintMapper;
|
|
@Autowired
|
|
@Autowired
|
|
private WarehouseBaseInfoMapper warehouseBaseInfoMapper;
|
|
private WarehouseBaseInfoMapper warehouseBaseInfoMapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ private INewWorkflowService workflowService;
|
|
@Override
|
|
@Override
|
|
public Page<PurchasePrice> purchasePriceList(PurchasePrice purchasePrice) {
|
|
public Page<PurchasePrice> purchasePriceList(PurchasePrice purchasePrice) {
|
|
|
|
|
|
@@ -51,6 +60,19 @@ public class PurchasePriceServiceImpl extends ServiceImpl<PurchasePriceMapper, P
|
|
|
|
|
|
Integer dataCount = this.baseMapper.purchasePriceListCount(pageView);
|
|
Integer dataCount = this.baseMapper.purchasePriceListCount(pageView);
|
|
|
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(dataList)) {
|
|
|
|
+ dataList.forEach(purchasePrice1 -> {
|
|
|
|
+
|
|
|
|
+ String taskId = "";
|
|
|
|
+ // 只有待审核状态才有taskId
|
|
|
|
+ if (StringUtils.isNotBlank(purchasePrice1.getWorkflowId())) {
|
|
|
|
+ JSONObject jsonObject = workflowService.getActiveTask(Lists.newArrayList(purchasePrice1.getWorkflowId()), purchasePrice1.getId());
|
|
|
|
+ taskId = jsonObject.getString("taskId");
|
|
|
|
+ purchasePrice1.setTaskId(taskId);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ }
|
|
Page<PurchasePrice> page = new Page<>();
|
|
Page<PurchasePrice> page = new Page<>();
|
|
page.setRecords(dataList == null ? Lists.newArrayList() : dataList);
|
|
page.setRecords(dataList == null ? Lists.newArrayList() : dataList);
|
|
page.setTotal(dataCount == null ? 0 : dataCount);
|
|
page.setTotal(dataCount == null ? 0 : dataCount);
|
|
@@ -70,6 +92,31 @@ public class PurchasePriceServiceImpl extends ServiceImpl<PurchasePriceMapper, P
|
|
purchasePrice.setStatusFlag(StatusEnum.PURCHASE_REVIEWED.getFlag());
|
|
purchasePrice.setStatusFlag(StatusEnum.PURCHASE_REVIEWED.getFlag());
|
|
// 操作主表数据
|
|
// 操作主表数据
|
|
this.insert(purchasePrice);
|
|
this.insert(purchasePrice);
|
|
|
|
+ boolean isStartWorkflow = StringUtils.isBlank(purchasePrice.getWorkflowId());
|
|
|
|
+ // 不是退回的单子
|
|
|
|
+ if (isStartWorkflow) {
|
|
|
|
+ Workflow workflow = workflowService
|
|
|
|
+ .findLatestWorkflowByBusinessCodeByApp(purchasePrice.getCompId(), "PROCUREMENT-PRICE-APPROVE");
|
|
|
|
+ // 没配置审核流程,直接结束并处理信息
|
|
|
|
+ if (workflow == null) {
|
|
|
|
+ throw new YException(YExceptionEnum.PURCHASE_ORDER_ERROR);
|
|
|
|
+ }
|
|
|
|
+ // 开启审核流
|
|
|
|
+ else {
|
|
|
|
+
|
|
|
|
+ // 设置状态 已提交审核
|
|
|
|
+ purchasePrice.setWorkflowId(workflow.getId());
|
|
|
|
+ this.updateById(purchasePrice);
|
|
|
|
+ workflowService.startInstance(workflow.getId(), purchasePrice.getId());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // 退回的单子 再启用
|
|
|
|
+ else {
|
|
|
|
+
|
|
|
|
+ this.updateById(purchasePrice);
|
|
|
|
+ workflowService.activateInstance(purchasePrice.getWorkflowId(), purchasePrice.getId());
|
|
|
|
+ }
|
|
|
|
+
|
|
// 操作明细表数据
|
|
// 操作明细表数据
|
|
for(PurchasePriceDetail tmp : purchasePrice.getDetails()){
|
|
for(PurchasePriceDetail tmp : purchasePrice.getDetails()){
|
|
tmp.setId(IdGenerator.generateUUID());
|
|
tmp.setId(IdGenerator.generateUUID());
|
|
@@ -123,6 +170,30 @@ public class PurchasePriceServiceImpl extends ServiceImpl<PurchasePriceMapper, P
|
|
tmp.setMainId(purchasePrice.getId());
|
|
tmp.setMainId(purchasePrice.getId());
|
|
this.purchasePriceDetailPrintMapper.insert(tmp);
|
|
this.purchasePriceDetailPrintMapper.insert(tmp);
|
|
}
|
|
}
|
|
|
|
+ boolean isStartWorkflow = StringUtils.isBlank(purchasePrice.getWorkflowId());
|
|
|
|
+ // 不是退回的单子
|
|
|
|
+ if (isStartWorkflow) {
|
|
|
|
+ Workflow workflow = workflowService
|
|
|
|
+ .findLatestWorkflowByBusinessCodeByApp(purchasePrice.getCompId(), "PROCUREMENT-PRICE-APPROVE");
|
|
|
|
+ // 没配置审核流程,直接结束并处理信息
|
|
|
|
+ if (workflow == null) {
|
|
|
|
+ throw new YException(YExceptionEnum.PURCHASE_ORDER_ERROR);
|
|
|
|
+ }
|
|
|
|
+ // 开启审核流
|
|
|
|
+ else {
|
|
|
|
+
|
|
|
|
+ // 设置状态 已提交审核
|
|
|
|
+ purchasePrice.setWorkflowId(workflow.getId());
|
|
|
|
+ this.updateById(purchasePrice);
|
|
|
|
+ workflowService.startInstance(workflow.getId(), purchasePrice.getId());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // 退回的单子 再启用
|
|
|
|
+ else {
|
|
|
|
+
|
|
|
|
+ this.updateById(purchasePrice);
|
|
|
|
+ workflowService.activateInstance(purchasePrice.getWorkflowId(), purchasePrice.getId());
|
|
|
|
+ }
|
|
return "ok";
|
|
return "ok";
|
|
}
|
|
}
|
|
|
|
|