|
@@ -1,5 +1,6 @@
|
|
|
package com.yh.saas.plugin.yiliangyiyun.service.impl;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.alipay.sofa.runtime.api.annotation.SofaReference;
|
|
|
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
|
|
import com.baomidou.mybatisplus.plugins.Page;
|
|
@@ -8,8 +9,11 @@ import com.winsea.svc.base.base.entity.CommonRoleResource;
|
|
|
import com.winsea.svc.base.base.service.ICommonRoleResourceService;
|
|
|
import com.winsea.svc.base.security.entity.User;
|
|
|
import com.winsea.svc.base.security.util.AuthSecurityUtils;
|
|
|
+import com.winsea.svc.base.workflow.entity.Workflow;
|
|
|
import com.yh.saas.plugin.yiliangyiyun.constant.StatusEnum;
|
|
|
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.SalesDeliveryReportMapper;
|
|
|
import com.yh.saas.plugin.yiliangyiyun.service.IContractManagementInfoService;
|
|
|
import com.yh.saas.plugin.yiliangyiyun.service.ISaleOrderService;
|
|
@@ -17,6 +21,7 @@ import com.yh.saas.plugin.yiliangyiyun.service.ISalesDeliveryReportService;
|
|
|
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
|
|
|
import com.yh.saas.plugin.yiliangyiyun.service.IWarehouseInOutInfoService;
|
|
|
import com.yh.saas.toolkit.workflow.service.IWorkflowService;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
@@ -57,14 +62,14 @@ public class SalesDeliveryReportServiceImpl extends ServiceImpl<SalesDeliveryRep
|
|
|
Map<String, Object> pageView = new HashMap<>();
|
|
|
pageView.put("startRecord", (salesDeliveryReport.getCurrentPage() - 1)
|
|
|
* salesDeliveryReport.getPageSize());
|
|
|
-// List<String> businessKeys = null;
|
|
|
-// businessKeys = workflowService.getTaskBusinessKeysByCode("PURCHASE-RECEIPT-REPORT");
|
|
|
-// List<String> statusSet = new ArrayList<>();
|
|
|
-// List<String> resourceIdList = this.getResourceIdList();
|
|
|
-// if (resourceIdList.contains("PURCHAS")) { // 填写,提交 权限做完以后替换
|
|
|
-// List<String> statusList = Lists.newArrayList(StatusEnum.PUR_RETURN.getFlag());
|
|
|
-// statusSet.addAll(statusList);
|
|
|
-// }
|
|
|
+ List<String> businessKeys = null;
|
|
|
+ businessKeys = workflowService.getTaskBusinessKeysByCode("SALE-RECEIPT-REPORT");
|
|
|
+ List<String> statusSet = new ArrayList<>();
|
|
|
+ List<String> resourceIdList = this.getResourceIdList();
|
|
|
+ if (resourceIdList.contains("saleOutReport-Edit")) { // 填写,提交 权限做完以后替换
|
|
|
+ List<String> statusList = Lists.newArrayList(StatusEnum.PUR_RETURN.getFlag());
|
|
|
+ statusSet.addAll(statusList);
|
|
|
+ }
|
|
|
//公司id
|
|
|
pageView.put("compId", salesDeliveryReport.getCompId());
|
|
|
pageView.put("searchKeyWord", salesDeliveryReport.getSearchKeyWord());
|
|
@@ -73,11 +78,24 @@ public class SalesDeliveryReportServiceImpl extends ServiceImpl<SalesDeliveryRep
|
|
|
pageView.put("currentPage", salesDeliveryReport.getCurrentPage());
|
|
|
pageView.put("contractNo", salesDeliveryReport.getContractNo());
|
|
|
pageView.put("roleFlag", salesDeliveryReport.getRoleFlag());
|
|
|
-// pageView.put("businessKeys", businessKeys);
|
|
|
-// pageView.put("statusSet", statusSet);
|
|
|
+ pageView.put("businessKeys", businessKeys);
|
|
|
+ pageView.put("statusSet", statusSet);
|
|
|
// 查询销售出库总数
|
|
|
Integer dataCount = baseMapper.getCountByCondition(pageView);
|
|
|
List<SalesDeliveryReport> dataList = baseMapper.getListByCondition(pageView);
|
|
|
+ if(!CollectionUtils.isEmpty(dataList)){
|
|
|
+ dataList.forEach(salesDeliveryReport1 -> {
|
|
|
+
|
|
|
+ String taskId = "";
|
|
|
+ // 只有待审核状态才有taskId
|
|
|
+ if (StringUtils.isNotBlank(salesDeliveryReport1.getWorkflowId())) {
|
|
|
+ JSONObject jsonObject = workflowService.getActiveTask(Lists.newArrayList(salesDeliveryReport1.getWorkflowId()), salesDeliveryReport1.getId());
|
|
|
+ taskId = jsonObject.getString("taskId");
|
|
|
+ salesDeliveryReport1.setTaskId(taskId);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
Page<SalesDeliveryReport> page = new Page<>();
|
|
|
page.setRecords(dataList == null ? Lists.newArrayList() : dataList);
|
|
|
page.setTotal(dataCount == null ? 0 : dataCount);
|
|
@@ -174,6 +192,32 @@ public class SalesDeliveryReportServiceImpl extends ServiceImpl<SalesDeliveryRep
|
|
|
@Override
|
|
|
public String editSalesDeliveryReport(SalesDeliveryReport salesDeliveryReport) {
|
|
|
boolean one = this.updateById(salesDeliveryReport);
|
|
|
+ if(salesDeliveryReport.getStatusFlag().equals(StatusEnum.TASK_RETURN.getFlag())) {
|
|
|
+ boolean isStartWorkflow = org.apache.commons.lang3.StringUtils.isBlank(salesDeliveryReport.getWorkflowId());
|
|
|
+ // 不是退回的单子
|
|
|
+ if (isStartWorkflow) {
|
|
|
+ Workflow workflow = workflowService
|
|
|
+ .findLatestWorkflowByBusinessCode("SALE-RECEIPT-REPORT");
|
|
|
+ // 没配置审核流程,直接结束并处理信息
|
|
|
+ if (workflow == null) {
|
|
|
+ throw new YException(YExceptionEnum.PURCHASE_ORDER_ERROR);
|
|
|
+ }
|
|
|
+ // 开启审核流
|
|
|
+ else {
|
|
|
+
|
|
|
+ // 设置状态 已提交审核
|
|
|
+ salesDeliveryReport.setWorkflowId(workflow.getId());
|
|
|
+ this.updateById(salesDeliveryReport);
|
|
|
+ workflowService.startInstance(workflow.getId(), salesDeliveryReport.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 退回的单子 再启用
|
|
|
+ else {
|
|
|
+
|
|
|
+ this.updateById(salesDeliveryReport);
|
|
|
+ workflowService.activateInstance(salesDeliveryReport.getWorkflowId(), salesDeliveryReport.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
if (one) {
|
|
|
return "OK";
|
|
|
} else {
|