|
@@ -1,10 +1,29 @@
|
|
|
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.plugins.Page;
|
|
|
+import com.google.common.collect.Lists;
|
|
|
+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.yh.saas.plugin.yiliangyiyun.constant.StatusEnum;
|
|
|
import com.yh.saas.plugin.yiliangyiyun.entity.ExpenseInfo;
|
|
|
import com.yh.saas.plugin.yiliangyiyun.mapper.ExpenseInfoMapper;
|
|
|
import com.yh.saas.plugin.yiliangyiyun.service.IExpenseInfoService;
|
|
|
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.service.INewWorkflowService;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -16,5 +35,62 @@ import org.springframework.stereotype.Service;
|
|
|
*/
|
|
|
@Service
|
|
|
public class ExpenseInfoServiceImpl extends ServiceImpl<ExpenseInfoMapper, ExpenseInfo> implements IExpenseInfoService {
|
|
|
+ @Autowired
|
|
|
+ private INewWorkflowService workflowService;
|
|
|
+ @SofaReference
|
|
|
+ private ICommonRoleResourceService roleResourceService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Page<ExpenseInfo> selectInfo(ExpenseInfo expenseInfo) {
|
|
|
+ Map<String, Object> pageView = new HashMap<>();
|
|
|
+ pageView.put("startRecord", (expenseInfo.getCurrentPage() - 1)
|
|
|
+ * expenseInfo.getPageSize());
|
|
|
+ List<String> businessKeys = null;
|
|
|
+ if ("2".equals(expenseInfo.getSearchType())) {
|
|
|
+ businessKeys = workflowService.getTaskBusinessKeysByCode("COLLECTION-WAREHOUSING-RECORD");
|
|
|
+ }
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ pageView.put("searchKeyWord", expenseInfo.getSearchKeyWord());
|
|
|
+ pageView.put("searchType", expenseInfo.getSearchType());
|
|
|
+ pageView.put("pageSize", expenseInfo.getPageSize());
|
|
|
+ pageView.put("currentPage", expenseInfo.getCurrentPage());
|
|
|
+ pageView.put("contractNo", expenseInfo.getContractNo());
|
|
|
+ pageView.put("startDate", expenseInfo.getStartDate());
|
|
|
+ pageView.put("endDate", expenseInfo.getEndDate());
|
|
|
+ pageView.put("businessKeys", businessKeys);
|
|
|
+ pageView.put("statusSet", statusSet);
|
|
|
+ // 查询总数
|
|
|
+ Integer dataCount = baseMapper.getCountByCondition(pageView);
|
|
|
+ List<ExpenseInfo> dataList = baseMapper.getListByCondition(pageView);
|
|
|
+ if (!CollectionUtils.isEmpty(dataList)) {
|
|
|
+ dataList.forEach(expenseInfo1 -> {
|
|
|
+ String taskId = "";
|
|
|
+ // 只有待审核状态才有taskId
|
|
|
+ if (StringUtils.isNotBlank(expenseInfo1.getWorkflowId())) {
|
|
|
+ JSONObject jsonObject = workflowService.getActiveTask(Lists.newArrayList(expenseInfo1.getWorkflowId()), expenseInfo1.getId());
|
|
|
+ taskId = jsonObject.getString("taskId");
|
|
|
+ expenseInfo1.setTaskId(taskId);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+ Page<ExpenseInfo> page = new Page<>();
|
|
|
+ page.setRecords(dataList == null ? Lists.newArrayList() : dataList);
|
|
|
+ page.setTotal(dataCount == null ? 0 : dataCount);
|
|
|
+ page.setCurrent(expenseInfo.getCurrentPage());
|
|
|
+ page.setSize(expenseInfo.getPageSize());
|
|
|
+ return page;
|
|
|
+ }
|
|
|
|
|
|
+ private List<String> getResourceIdList() {
|
|
|
+ User currentUser = AuthSecurityUtils.getCurrentUserInfo();
|
|
|
+ // 当前登录人主要角色
|
|
|
+ return roleResourceService.getBindResourcesByUserId(currentUser.getUserId()).stream()
|
|
|
+ .map(CommonRoleResource::getResourceId).collect(Collectors.toList());
|
|
|
+ }
|
|
|
}
|