|
@@ -2,27 +2,36 @@ package com.yh.saas.plugin.yiliangyiyun.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alipay.sofa.runtime.api.annotation.SofaReference;
|
|
import com.alipay.sofa.runtime.api.annotation.SofaReference;
|
|
|
|
+import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
|
|
|
+import com.baomidou.mybatisplus.mapper.Wrapper;
|
|
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.base.entity.CommonRoleResource;
|
|
import com.winsea.svc.base.base.entity.CommonRoleResource;
|
|
import com.winsea.svc.base.base.service.ICommonRoleResourceService;
|
|
import com.winsea.svc.base.base.service.ICommonRoleResourceService;
|
|
import com.winsea.svc.base.security.entity.User;
|
|
import com.winsea.svc.base.security.entity.User;
|
|
import com.winsea.svc.base.security.util.AuthSecurityUtils;
|
|
import com.winsea.svc.base.security.util.AuthSecurityUtils;
|
|
|
|
+import com.winsea.svc.base.workflow.entity.Workflow;
|
|
|
|
+import com.yh.saas.common.support.util.IdGenerator;
|
|
|
|
+import com.yh.saas.plugin.base.service.ICommonBillOperateHisService;
|
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.constant.NumberConstant;
|
|
import com.yh.saas.plugin.yiliangyiyun.constant.StatusEnum;
|
|
import com.yh.saas.plugin.yiliangyiyun.constant.StatusEnum;
|
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.entity.ExpenseAllocationInfo;
|
|
import com.yh.saas.plugin.yiliangyiyun.entity.ExpenseInfo;
|
|
import com.yh.saas.plugin.yiliangyiyun.entity.ExpenseInfo;
|
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.entity.WarehousingOrder;
|
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.exception.YException;
|
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.exception.YExceptionEnum;
|
|
import com.yh.saas.plugin.yiliangyiyun.mapper.ExpenseInfoMapper;
|
|
import com.yh.saas.plugin.yiliangyiyun.mapper.ExpenseInfoMapper;
|
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.service.IExpenseAllocationInfoService;
|
|
import com.yh.saas.plugin.yiliangyiyun.service.IExpenseInfoService;
|
|
import com.yh.saas.plugin.yiliangyiyun.service.IExpenseInfoService;
|
|
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
|
|
import com.yh.saas.plugin.yiliangyiyun.service.INewWorkflowService;
|
|
import com.yh.saas.plugin.yiliangyiyun.service.INewWorkflowService;
|
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.service.IWarehousingOrderService;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
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.util.CollectionUtils;
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
|
-import java.util.HashMap;
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.Map;
|
|
|
|
|
|
+import java.util.*;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -39,6 +48,12 @@ public class ExpenseInfoServiceImpl extends ServiceImpl<ExpenseInfoMapper, Expen
|
|
private INewWorkflowService workflowService;
|
|
private INewWorkflowService workflowService;
|
|
@SofaReference
|
|
@SofaReference
|
|
private ICommonRoleResourceService roleResourceService;
|
|
private ICommonRoleResourceService roleResourceService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IExpenseAllocationInfoService expenseAllocationInfoService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ICommonBillOperateHisService billOperateHisService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IWarehousingOrderService warehousingOrderService;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public Page<ExpenseInfo> selectInfo(ExpenseInfo expenseInfo) {
|
|
public Page<ExpenseInfo> selectInfo(ExpenseInfo expenseInfo) {
|
|
@@ -87,6 +102,188 @@ public class ExpenseInfoServiceImpl extends ServiceImpl<ExpenseInfoMapper, Expen
|
|
return page;
|
|
return page;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 查看
|
|
|
|
+ * @param id
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public ExpenseInfo getInfo(String id) {
|
|
|
|
+ ExpenseInfo expenseInfo=this.selectById(id);
|
|
|
|
+ //费用分配列表
|
|
|
|
+ List<ExpenseAllocationInfo> expenseAllocationInfos = expenseAllocationInfoService.selectList(new EntityWrapper<ExpenseAllocationInfo>()
|
|
|
|
+ .eq("info_id", id));
|
|
|
|
+ if (!CollectionUtils.isEmpty(expenseAllocationInfos)) {
|
|
|
|
+ expenseInfo.setExpenseAllocationInfoList(expenseAllocationInfos);
|
|
|
|
+ }
|
|
|
|
+ return expenseInfo;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 删除
|
|
|
|
+ * @param id
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public void deleteInfo(String id) {
|
|
|
|
+ ExpenseInfo expenseInfo=this.selectById(id);
|
|
|
|
+ if (expenseInfo != null) {
|
|
|
|
+ this.deleteById(expenseInfo.getId());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public String addInfo(ExpenseInfo expenseInfo) {
|
|
|
|
+ expenseInfo.setId(IdGenerator.generateUUID());
|
|
|
|
+ //收入
|
|
|
|
+ if ("1".equals(expenseInfo.getExpensesType())){
|
|
|
|
+ this.insert(expenseInfo);
|
|
|
|
+ }
|
|
|
|
+ //支出
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ expenseInfo.setStatusFlag(StatusEnum.COST_PAYMENT.getFlag());
|
|
|
|
+ expenseInfo.setStatus(StatusEnum.COST_PAYMENT.getName());
|
|
|
|
+ this.insert(expenseInfo);
|
|
|
|
+ //分配列表
|
|
|
|
+ List<ExpenseAllocationInfo> expenseAllocationInfoList = expenseInfo.getExpenseAllocationInfoList();
|
|
|
|
+ if (!CollectionUtils.isEmpty(expenseAllocationInfoList)) {
|
|
|
|
+ for (ExpenseAllocationInfo expenseAllocationInfo : expenseAllocationInfoList) {
|
|
|
|
+ expenseAllocationInfo.setId(IdGenerator.generateUUID());
|
|
|
|
+ expenseAllocationInfo.setInfoId(expenseInfo.getId());
|
|
|
|
+ expenseAllocationInfo.setStatusFlag(StatusEnum.TO_BE_CONFIRMED.getFlag());
|
|
|
|
+ expenseAllocationInfo.setStatus(StatusEnum.TO_BE_CONFIRMED.getName());
|
|
|
|
+ }
|
|
|
|
+ expenseAllocationInfoService.insertBatch(expenseAllocationInfoList);
|
|
|
|
+ }
|
|
|
|
+ // 插入操作历史
|
|
|
|
+ String staffName = this.billOperateHisService.getStaffAndName();
|
|
|
|
+ // 插入操作历史
|
|
|
|
+ this.billOperateHisService.saveBillOperateHis(expenseInfo.getId(), NumberConstant.EXPENSE_MANAGEMENT, staffName, null,
|
|
|
|
+ "请款"+"("+expenseInfo.getAmountMoney()+")", null, expenseInfo.getRemark());
|
|
|
|
+ boolean isStartWorkflow = StringUtils.isBlank(expenseInfo.getWorkflowId());
|
|
|
|
+ // 不是退回的单子
|
|
|
|
+ if (isStartWorkflow) {
|
|
|
|
+ Workflow workflow = workflowService
|
|
|
|
+ .findLatestWorkflowByBusinessCodeByApp(expenseInfo.getCompId(), "EX-CONTRACT-APPROVE");
|
|
|
|
+ // 没配置审核流程,直接结束并处理信息
|
|
|
|
+ if (workflow == null) {
|
|
|
|
+ throw new YException(YExceptionEnum.PURCHASE_ORDER_ERROR);
|
|
|
|
+ }
|
|
|
|
+ // 开启审核流
|
|
|
|
+ else {
|
|
|
|
+ // 设置状态 已提交审核
|
|
|
|
+ expenseInfo.setWorkflowId(workflow.getId());
|
|
|
|
+ this.updateById(expenseInfo);
|
|
|
|
+ workflowService.startInstance(workflow.getId(), expenseInfo.getId());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // 退回的单子 再启用
|
|
|
|
+ else {
|
|
|
|
+ this.updateById(expenseInfo);
|
|
|
|
+ workflowService.activateInstance(expenseInfo.getWorkflowId(), expenseInfo.getId());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return "ok";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public String editInfo(ExpenseInfo expenseInfo) {
|
|
|
|
+ //确认收款
|
|
|
|
+ if ("0".equals(expenseInfo.getFlag())) {
|
|
|
|
+ expenseInfo.setStatusFlag(StatusEnum.COST_RECEIVED.getFlag());
|
|
|
|
+ expenseInfo.setStatus(StatusEnum.COST_RECEIVED.getName());
|
|
|
|
+ }
|
|
|
|
+ //完成收款
|
|
|
|
+ else if ("1".equals(expenseInfo.getFlag())){
|
|
|
|
+ expenseInfo.setStatusFlag(StatusEnum.COMPLETED.getFlag());
|
|
|
|
+ expenseInfo.setStatus(StatusEnum.COMPLETED.getName());
|
|
|
|
+ }
|
|
|
|
+ //确认分配
|
|
|
|
+ else if ("2".equals(expenseInfo.getFlag())){
|
|
|
|
+ expenseInfo.setDistributionStatusFlag(StatusEnum.COMPLETED.getFlag());
|
|
|
|
+ expenseInfo.setDistributionStatus(StatusEnum.COMPLETED.getName());
|
|
|
|
+ List<ExpenseAllocationInfo> expenseAllocationInfos=expenseAllocationInfoService.selectList(new EntityWrapper<ExpenseAllocationInfo>()
|
|
|
|
+ .eq("info_id",expenseInfo.getId())
|
|
|
|
+ .eq("status","待确认"));
|
|
|
|
+ if (!CollectionUtils.isEmpty(expenseAllocationInfos)){
|
|
|
|
+ for (ExpenseAllocationInfo expenseAllocationInfo:expenseAllocationInfos){
|
|
|
|
+ expenseAllocationInfo.setStatusFlag(StatusEnum.COST_ADOPTED.getFlag());
|
|
|
|
+ expenseAllocationInfo.setStatus(StatusEnum.COST_ADOPTED.getName());
|
|
|
|
+ expenseAllocationInfoService.updateById(expenseAllocationInfo);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //编辑分配
|
|
|
|
+ else {
|
|
|
|
+ List<ExpenseAllocationInfo> expenseAllocationInfoList = expenseInfo.getExpenseAllocationInfoList();
|
|
|
|
+ if (!CollectionUtils.isEmpty(expenseAllocationInfoList)) {
|
|
|
|
+ for (ExpenseAllocationInfo expenseAllocationInfo : expenseAllocationInfoList) {
|
|
|
|
+ expenseAllocationInfoService.updateById(expenseAllocationInfo);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 主表信息编辑
|
|
|
|
+ boolean one = this.updateById(expenseInfo);
|
|
|
|
+ // 假如成功返回ok
|
|
|
|
+ if (one) {
|
|
|
|
+ return "OK";
|
|
|
|
+ } else {
|
|
|
|
+ return "NG";
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 付款
|
|
|
|
+ * @param expenseInfo
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public String payment(ExpenseInfo expenseInfo) {
|
|
|
|
+ expenseInfo.setStatusFlag(StatusEnum.COST_PAID.getFlag());
|
|
|
|
+ expenseInfo.setStatus(StatusEnum.COST_PAID.getName());
|
|
|
|
+ this.updateById(expenseInfo);
|
|
|
|
+ // 插入操作历史
|
|
|
|
+ String staffName = this.billOperateHisService.getStaffAndName();
|
|
|
|
+ // 插入操作历史
|
|
|
|
+ this.billOperateHisService.saveBillOperateHis(expenseInfo.getId(), NumberConstant.EXPENSE_MANAGEMENT, staffName, null,
|
|
|
|
+ "付款"+"("+expenseInfo.getAmountMoney()+")", null, "");
|
|
|
|
+ return "ok";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 删除分配
|
|
|
|
+ * @param id
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public void deleteAllocationInfo(String id) {
|
|
|
|
+ List<ExpenseAllocationInfo> expenseAllocationInfos=expenseAllocationInfoService.selectList(new EntityWrapper<ExpenseAllocationInfo>()
|
|
|
|
+ .eq("info_id",id)
|
|
|
|
+ .ne("status","已通过"));
|
|
|
|
+ if (!CollectionUtils.isEmpty(expenseAllocationInfos)){
|
|
|
|
+ for (ExpenseAllocationInfo expenseAllocationInfo:expenseAllocationInfos){
|
|
|
|
+ expenseAllocationInfoService.deleteInfo(expenseAllocationInfo.getId());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public List<WarehousingOrder> selectWarehousingOrder(String contractNo, String warehouseName, String receiptDocDate) {
|
|
|
|
+ Wrapper<WarehousingOrder> warehousingOrderWrapper = new EntityWrapper<>();
|
|
|
|
+ if (contractNo!=null){
|
|
|
|
+ warehousingOrderWrapper.eq("contract_no", contractNo);
|
|
|
|
+ }
|
|
|
|
+ if (warehouseName!=null){
|
|
|
|
+ warehousingOrderWrapper.eq("warehouse_name", warehouseName);
|
|
|
|
+ }
|
|
|
|
+ if (receiptDocDate!=null){
|
|
|
|
+ warehousingOrderWrapper.like("issuing_time", receiptDocDate);
|
|
|
|
+ }
|
|
|
|
+ warehousingOrderWrapper.orderBy("update_date");
|
|
|
|
+ List<WarehousingOrder> warehousingOrderList = warehousingOrderService.selectList(warehousingOrderWrapper);
|
|
|
|
+ return warehousingOrderList;
|
|
|
|
+ }
|
|
|
|
+
|
|
private List<String> getResourceIdList() {
|
|
private List<String> getResourceIdList() {
|
|
User currentUser = AuthSecurityUtils.getCurrentUserInfo();
|
|
User currentUser = AuthSecurityUtils.getCurrentUserInfo();
|
|
// 当前登录人主要角色
|
|
// 当前登录人主要角色
|