Browse Source

[feat]:新增: 报销单子表新增根据子表查询子表list列表信息。

dev
zhangsiqi 3 months ago
parent
commit
cbcd867a69
  1. 156
      ruoyi-admin/src/main/java/com/ruoyi/financial/controller/FinacialExpenseController.java
  2. 93
      ruoyi-admin/src/main/java/com/ruoyi/financial/domain/FinacialExpense.java
  3. 101
      ruoyi-admin/src/main/java/com/ruoyi/financial/domain/VO/FinacialExpenseVo.java
  4. 3
      ruoyi-admin/src/main/java/com/ruoyi/financial/mapper/FinacialExpenseMapper.java
  5. 29
      ruoyi-admin/src/main/java/com/ruoyi/financial/service/IFinacialExpenseService.java
  6. 189
      ruoyi-admin/src/main/java/com/ruoyi/financial/service/impl/FinacialExpenseChild.java
  7. 126
      ruoyi-admin/src/main/java/com/ruoyi/financial/service/impl/FinacialExpenseServiceImpl.java
  8. 417
      ruoyi-admin/src/main/java/com/ruoyi/financial/service/impl/FinancialExpenseServiceImpl.java
  9. 144
      ruoyi-admin/src/main/resources/mapper/financial/FinacialExpenseMapper.xml
  10. 176
      ruoyi-admin/src/main/resources/templates/financial/expense/expense.html

156
ruoyi-admin/src/main/java/com/ruoyi/financial/controller/FinacialExpenseController.java

@ -1,15 +1,23 @@
package com.ruoyi.financial.controller; package com.ruoyi.financial.controller;
import java.util.HashMap;
import java.util.List; import java.util.List;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.process.general.service.IProcessService;
import com.ruoyi.remind.service.RemindService;
import com.ruoyi.financial.domain.VO.FinacialExpenseVo;
import com.ruoyi.system.service.*;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.TaskService;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap; import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log; import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.financial.domain.FinacialExpense; import com.ruoyi.financial.domain.FinacialExpense;
@ -19,6 +27,9 @@ import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.core.page.TableDataInfo;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
/** /**
* 报销管理Controller * 报销管理Controller
* *
@ -34,6 +45,28 @@ public class FinacialExpenseController extends BaseController
@Autowired @Autowired
private IFinacialExpenseService finacialExpenseService; private IFinacialExpenseService finacialExpenseService;
@Autowired
private RedisCache redisCache;
@Autowired
private ISysDictTypeService sysDictTypeService;
@Autowired
private RemindService remindService;
@Autowired
private ISysRoleService roleService;
@Autowired
private TaskService taskService;
@Autowired
private RuntimeService runtimeService;
@Autowired
private ISysUserService sysUserService;
@Autowired
private IProcessService processService;
@RequiresPermissions("financial:expense:view") @RequiresPermissions("financial:expense:view")
@GetMapping() @GetMapping()
public String expense() public String expense()
@ -57,16 +90,16 @@ public class FinacialExpenseController extends BaseController
/** /**
* 导出报销管理列表 * 导出报销管理列表
*/ */
@RequiresPermissions("financial:expense:export") // @RequiresPermissions("financial:expense:export")
@Log(title = "报销管理", businessType = BusinessType.EXPORT) // @Log(title = "报销管理", businessType = BusinessType.EXPORT)
@PostMapping("/export") // @PostMapping("/export")
@ResponseBody // @ResponseBody
public AjaxResult export(FinacialExpense finacialExpense) // public AjaxResult export(FinacialExpense finacialExpense)
{ // {
List<FinacialExpense> list = finacialExpenseService.selectFinacialExpenseList(finacialExpense); // List<FinacialExpense> list = finacialExpenseService.selectFinacialExpenseList(finacialExpense);
ExcelUtil<FinacialExpense> util = new ExcelUtil<FinacialExpense>(FinacialExpense.class); // ExcelUtil<FinacialExpense> util = new ExcelUtil<FinacialExpense>(FinacialExpense.class);
return util.exportExcel(list, "报销管理数据"); // return util.exportExcel(list, "报销管理数据");
} // }
/** /**
* 新增报销管理 * 新增报销管理
@ -123,12 +156,87 @@ public class FinacialExpenseController extends BaseController
{ {
return toAjax(finacialExpenseService.deleteFinacialExpenseByIds(ids)); return toAjax(finacialExpenseService.deleteFinacialExpenseByIds(ids));
} }
@GetMapping("/showVerifyDialog/{taskId}")
public String showVerifyDialog(@PathVariable("taskId") String taskId, ModelMap mmap) {
Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
String processInstanceId = task.getProcessInstanceId();
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
FinacialExpense finacialExpense = finacialExpenseService.selectFinacialExpenseById(new Long(processInstance.getBusinessKey()));
mmap.put("formData", finacialExpense);
mmap.put("taskId", taskId);
String verifyName = task.getTaskDefinitionKey().substring(0, 1).toUpperCase() + task.getTaskDefinitionKey().substring(1);
return prefix + "/task" + verifyName;
}
@ModelAttribute("/preloadObj")
public FinacialExpense getObj(@RequestParam(value = "expenseId", required = false) Long expenseId, HttpSession session) {
if (expenseId != null) {
return finacialExpenseService.selectFinacialExpenseById(expenseId);
}
return new FinacialExpense();
}
/**
* 完成任务
*
* @return
*/
@RequestMapping(value = "/complete/{taskId}", method = {RequestMethod.POST, RequestMethod.GET})
@ResponseBody
public AjaxResult complete(@PathVariable("taskId") String taskId, @RequestParam(value = "saveEntity", required = false) String saveEntity,
@ModelAttribute("preloadObj") FinacialExpenseVo finacialExpenseVo, HttpServletRequest request) {
boolean saveEntityBoolean = BooleanUtils.toBoolean(saveEntity);
if (saveEntityBoolean){
finacialExpenseService.updateFinacialExpense(finacialExpenseVo);
}
String instanceId = finacialExpenseVo.getInstanceId();
String instanceType = finacialExpenseVo.getInstanceType();
boolean approvedFlag = processService.complete(taskId, instanceId, finacialExpenseVo.getApplyTitle(),
finacialExpenseVo.getExpenseCode(),
"expense", new HashMap<String, Object>(), request);
if(!approvedFlag){
// 审核状态-审核拒绝
finacialExpenseVo.setAuditStatus("2");
}
// 如果任务已结束更新业务表状态 方法中传入的值为原来的instanceId,只是做了调整
boolean processIsFinish = processService.judgeProcessIsFinish(instanceId);
if (processIsFinish) {
// 审核通过
finacialExpenseVo.setAuditStatus("1");
finacialExpenseVo.setFinanceAuditStatus("0");
finacialExpenseVo.setManagerAuditStatus("1");
// 提交
if("submit".equals(instanceType)){
// 使用状态-是
finacialExpenseVo.setUseStatus("1");
//总经理审核完毕为转入财务审核,如果是总经理审核的话,财务审核状态为0
if(finacialExpenseVo.getTaskName().contains("总经理")){
finacialExpenseVo.setManagerAuditStatus("1");
finacialExpenseService.updateFinacialExpense(finacialExpenseVo);
}
}
// 作废
else if("cancel".equals(instanceType)){
// 使用状态-已作废
finacialExpenseVo.setUseStatus("2");
}
// 恢复
else if("restore".equals(instanceType)){
// 使用状态-是
finacialExpenseVo.setUseStatus("1");
}
}
finacialExpenseService.updateFinacialExpense(finacialExpenseVo);
// 驳回申请后继续申请,可能修改表单
if (saveEntityBoolean) {
finacialExpenseService.updateFinacialExpense(finacialExpenseVo);
}
return success("任务已完成");
}
/** /**
* 作废报销管理 * 作废报销
*/ */
@RequiresPermissions("financial:expense:cancel") @RequiresPermissions("system:baseExpense:cancel")
@Log(title = "报销管理", businessType = BusinessType.CANCEL) @Log(title = "报销", businessType = BusinessType.CANCEL)
@GetMapping( "/cancel/{id}") @GetMapping( "/cancel/{id}")
@ResponseBody @ResponseBody
public AjaxResult cancel(@PathVariable("id") Long id){ public AjaxResult cancel(@PathVariable("id") Long id){
@ -136,10 +244,10 @@ public class FinacialExpenseController extends BaseController
} }
/** /**
* 恢复报销管理 * 恢复报销
*/ */
@RequiresPermissions("financial:expense:restore") @RequiresPermissions("system:baseExpense:restore")
@Log(title = "报销管理", businessType = BusinessType.RESTORE) @Log(title = "报销", businessType = BusinessType.RESTORE)
@GetMapping( "/restore/{id}") @GetMapping( "/restore/{id}")
@ResponseBody @ResponseBody
public AjaxResult restore(@PathVariable("id")Long id) public AjaxResult restore(@PathVariable("id")Long id)
@ -148,4 +256,10 @@ public class FinacialExpenseController extends BaseController
} }
@RequestMapping("/getExpenseUser")
@ResponseBody
public AjaxResult getExpenseCode() throws Exception {
return AjaxResult.success(sysUserService.selectUserAll());
}
} }

93
ruoyi-admin/src/main/java/com/ruoyi/financial/domain/FinacialExpense.java

@ -1,10 +1,15 @@
package com.ruoyi.financial.domain; package com.ruoyi.financial.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.financial.service.impl.FinacialExpenseChild;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel; import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity; import com.ruoyi.common.core.domain.BaseEntity;
import java.util.Date;
import java.util.List;
/** /**
* 报销管理对象 finacial_expense * 报销管理对象 finacial_expense
* *
@ -81,6 +86,94 @@ public class FinacialExpense extends BaseEntity
/** 删除标志 */ /** 删除标志 */
private String delFlag; private String delFlag;
/** 流程实例ID */
private String instanceId;
/** 流程实例类型 */
private String instanceType;
/** 提交流程实例ID */
private String submitInstanceId;
/** 作废流程实例ID */
private String cancelInstanceId;
/** 恢复流程实例ID */
private String restoreInstanceId;
/** 申请人 */
private String applyTitle;
private List<FinacialExpenseChild> finacialExpenseChildList;
public List<FinacialExpenseChild> getFinacialExpenseChildList() {
return finacialExpenseChildList;
}
public void setFinacialExpenseChildList(List<FinacialExpenseChild> finacialExpenseChildList) {
this.finacialExpenseChildList = finacialExpenseChildList;
}
/** 申请时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date applyTime;
public String getInstanceId() {
return instanceId;
}
public void setInstanceId(String instanceId) {
this.instanceId = instanceId;
}
public String getInstanceType() {
return instanceType;
}
public void setInstanceType(String instanceType) {
this.instanceType = instanceType;
}
public String getSubmitInstanceId() {
return submitInstanceId;
}
public void setSubmitInstanceId(String submitInstanceId) {
this.submitInstanceId = submitInstanceId;
}
public String getCancelInstanceId() {
return cancelInstanceId;
}
public void setCancelInstanceId(String cancelInstanceId) {
this.cancelInstanceId = cancelInstanceId;
}
public String getRestoreInstanceId() {
return restoreInstanceId;
}
public void setRestoreInstanceId(String restoreInstanceId) {
this.restoreInstanceId = restoreInstanceId;
}
public String getApplyTitle() {
return applyTitle;
}
public void setApplyTitle(String applyTitle) {
this.applyTitle = applyTitle;
}
public Date getApplyTime() {
return applyTime;
}
public void setApplyTime(Date applyTime) {
this.applyTime = applyTime;
}
public void setExpenseId(Long expenseId) public void setExpenseId(Long expenseId)
{ {
this.expenseId = expenseId; this.expenseId = expenseId;

101
ruoyi-admin/src/main/java/com/ruoyi/financial/domain/VO/FinacialExpenseVo.java

@ -0,0 +1,101 @@
package com.ruoyi.financial.domain.VO;
import com.ruoyi.financial.domain.FinacialExpense;
import java.util.Date;
public class FinacialExpenseVo extends FinacialExpense {
private static final long serialVersionUID = 1L;
/** 申请人姓名 */
private String applyUserName;
/** 任务ID */
private String taskId;
/** 任务名称 */
private String taskName;
/** 办理时间 */
private Date doneTime;
/** 创建人 */
private String createUserName;
/** 流程实例状态 1 激活 2 挂起 */
private String suspendState;
/** 待办用户id */
private String todoUserId;
/** 流程实例类型名称 */
private String instanceTypeName;
/**
* 关键词
*/
private String keyword;
public String getKeyword() {
return keyword;
}
public void setKeyword(String keyword) {
this.keyword = keyword;
}
public String getApplyUserName() {
return applyUserName;
}
public void setApplyUserName(String applyUserName) {
this.applyUserName = applyUserName;
}
public String getTaskId() {
return taskId;
}
public void setTaskId(String taskId) {
this.taskId = taskId;
}
public String getTaskName() {
return taskName;
}
public void setTaskName(String taskName) {
this.taskName = taskName;
}
public Date getDoneTime() {
return doneTime;
}
public void setDoneTime(Date doneTime) {
this.doneTime = doneTime;
}
public String getCreateUserName() {
return createUserName;
}
public void setCreateUserName(String createUserName) {
this.createUserName = createUserName;
}
public String getSuspendState() {
return suspendState;
}
public void setSuspendState(String suspendState) {
this.suspendState = suspendState;
}
public String getTodoUserId() {
return todoUserId;
}
public void setTodoUserId(String todoUserId) {
this.todoUserId = todoUserId;
}
public String getInstanceTypeName() {
return instanceTypeName;
}
public void setInstanceTypeName(String instanceTypeName) {
this.instanceTypeName = instanceTypeName;
}
}

3
ruoyi-admin/src/main/java/com/ruoyi/financial/mapper/FinacialExpenseMapper.java

@ -2,6 +2,7 @@ package com.ruoyi.financial.mapper;
import java.util.List; import java.util.List;
import com.ruoyi.financial.domain.FinacialExpense; import com.ruoyi.financial.domain.FinacialExpense;
import com.ruoyi.financial.domain.VO.FinacialExpenseVo;
/** /**
* 报销管理Mapper接口 * 报销管理Mapper接口
@ -17,7 +18,7 @@ public interface FinacialExpenseMapper
* @param expenseId 报销管理ID * @param expenseId 报销管理ID
* @return 报销管理 * @return 报销管理
*/ */
public FinacialExpense selectFinacialExpenseById(Long expenseId); public FinacialExpenseVo selectFinacialExpenseById(Long expenseId);
/** /**
* 查询报销管理列表 * 查询报销管理列表

29
ruoyi-admin/src/main/java/com/ruoyi/financial/service/IFinacialExpenseService.java

@ -2,6 +2,10 @@ package com.ruoyi.financial.service;
import java.util.List; import java.util.List;
import com.ruoyi.financial.domain.FinacialExpense; import com.ruoyi.financial.domain.FinacialExpense;
import com.ruoyi.financial.domain.VO.FinacialExpenseVo;
import com.ruoyi.system.domain.Vo.BaseExpenseAccountVo;
import org.activiti.engine.runtime.ProcessInstance;
import org.springframework.transaction.annotation.Transactional;
/** /**
* 报销管理Service接口 * 报销管理Service接口
@ -27,6 +31,14 @@ public interface IFinacialExpenseService
*/ */
public List<FinacialExpense> selectFinacialExpenseList(FinacialExpense finacialExpense); public List<FinacialExpense> selectFinacialExpenseList(FinacialExpense finacialExpense);
/**
* 查询报销管理列表
*
* @param finacialExpense 报销管理
* @return 报销管理集合
*/
public List<FinacialExpenseVo> selectFinacialExpenseList(FinacialExpenseVo finacialExpense);
/** /**
* 新增报销管理 * 新增报销管理
* *
@ -43,6 +55,7 @@ public interface IFinacialExpenseService
*/ */
public int updateFinacialExpense(FinacialExpense finacialExpense); public int updateFinacialExpense(FinacialExpense finacialExpense);
/** /**
* 批量删除报销管理 * 批量删除报销管理
* *
@ -72,4 +85,20 @@ public interface IFinacialExpenseService
* @return * @return
*/ */
int restoreFinacialExpenseById(Long expenseId); int restoreFinacialExpenseById(Long expenseId);
@Transactional(rollbackFor = Exception.class)
ProcessInstance cancelSysCustomerById(Long id);
@Transactional(rollbackFor = Exception.class)
ProcessInstance restoreSysCustomerById(Long id);
@Transactional(rollbackFor = Exception.class)
ProcessInstance submitApply(FinacialExpense finacialExpense);
@Transactional(rollbackFor = Exception.class)
ProcessInstance submitApply(BaseExpenseAccountVo baseExpenseAccountVo);
Object getId();
int insertFinacialExpense(BaseExpenseAccountVo baseExpenseAccountVo);
} }

189
ruoyi-admin/src/main/java/com/ruoyi/financial/service/impl/FinacialExpenseChild.java

@ -0,0 +1,189 @@
package com.ruoyi.financial.service.impl;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import java.util.Date;
public class FinacialExpenseChild extends BaseEntity {
private static final long serialVersionUID = 1L;
/** 报销单分项子表 */
private Long expenseChildId;
/** 关联报销单号 */
@Excel(name = "关联报销单号")
private String expenseCode;
/** 成本类型 */
@Excel(name = "成本类型")
private String costType;
/** 成本小类 */
@Excel(name = "成本小类")
private String costSmallType;
/** 用途 */
@Excel(name = "用途")
private String purpose;
/** 金额 */
@Excel(name = "金额")
private String amounts;
/** 报销时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "报销时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date expenseTime;
/** 出差单号 */
@Excel(name = "出差单号")
private String evectionCode;
/** 采购单号 */
@Excel(name = "采购单号")
private String purchaseCode;
/** 委外单号 */
@Excel(name = "委外单号")
private String outsourceCode;
/** 删除状态 */
private String delFlag;
private Integer index;
public void setExpenseChildId(Long expenseChildId)
{
this.expenseChildId = expenseChildId;
}
public Long getExpenseChildId()
{
return expenseChildId;
}
public void setExpenseCode(String expenseCode)
{
this.expenseCode = expenseCode;
}
public String getExpenseCode()
{
return expenseCode;
}
public void setCostType(String costType)
{
this.costType = costType;
}
public String getCostType()
{
return costType;
}
public void setCostSmallType(String costSmallType)
{
this.costSmallType = costSmallType;
}
public String getCostSmallType()
{
return costSmallType;
}
public void setPurpose(String purpose)
{
this.purpose = purpose;
}
public String getPurpose()
{
return purpose;
}
public void setAmounts(String amounts)
{
this.amounts = amounts;
}
public String getAmounts()
{
return amounts;
}
public void setExpenseTime(Date expenseTime)
{
this.expenseTime = expenseTime;
}
public Date getExpenseTime()
{
return expenseTime;
}
public void setEvectionCode(String evectionCode)
{
this.evectionCode = evectionCode;
}
public String getEvectionCode()
{
return evectionCode;
}
public void setPurchaseCode(String purchaseCode)
{
this.purchaseCode = purchaseCode;
}
public String getPurchaseCode()
{
return purchaseCode;
}
public void setOutsourceCode(String outsourceCode)
{
this.outsourceCode = outsourceCode;
}
public String getOutsourceCode()
{
return outsourceCode;
}
public void setDelFlag(String delFlag)
{
this.delFlag = delFlag;
}
public String getDelFlag()
{
return delFlag;
}
public Integer getIndex() {
return index;
}
public void setIndex(Integer index) {
this.index = index;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("expenseChildId", getExpenseChildId())
.append("expenseCode", getExpenseCode())
.append("cost type", getCostType())
.append("costSmallType", getCostSmallType())
.append("purpose", getPurpose())
.append("amounts", getAmounts())
.append("expenseTime", getExpenseTime())
.append("evectionCode", getEvectionCode())
.append("purchaseCode", getPurchaseCode())
.append("outsourceCode", getOutsourceCode())
.append("createTime", getCreateTime())
.append("createBy", getCreateBy())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("delFlag", getDelFlag())
.append("remark", getRemark())
.toString();
}
}

126
ruoyi-admin/src/main/java/com/ruoyi/financial/service/impl/FinacialExpenseServiceImpl.java

@ -1,126 +0,0 @@
package com.ruoyi.financial.service.impl;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ShiroUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.financial.mapper.FinacialExpenseMapper;
import com.ruoyi.financial.domain.FinacialExpense;
import com.ruoyi.financial.service.IFinacialExpenseService;
import com.ruoyi.common.core.text.Convert;
/**
* 报销管理Service业务层处理
*
* @author zhang
* @date 2024-05-31
*/
@Service
public class FinacialExpenseServiceImpl implements IFinacialExpenseService
{
@Autowired
private FinacialExpenseMapper finacialExpenseMapper;
/**
* 查询报销管理
*
* @param expenseId 报销管理ID
* @return 报销管理
*/
@Override
public FinacialExpense selectFinacialExpenseById(Long expenseId)
{
return finacialExpenseMapper.selectFinacialExpenseById(expenseId);
}
/**
* 查询报销管理列表
*
* @param finacialExpense 报销管理
* @return 报销管理
*/
@Override
public List<FinacialExpense> selectFinacialExpenseList(FinacialExpense finacialExpense)
{
return finacialExpenseMapper.selectFinacialExpenseList(finacialExpense);
}
/**
* 新增报销管理
*
* @param finacialExpense 报销管理
* @return 结果
*/
@Override
public int insertFinacialExpense(FinacialExpense finacialExpense)
{
String loginName = ShiroUtils.getLoginName();
finacialExpense.setCreateBy(loginName);
finacialExpense.setCreateTime(DateUtils.getNowDate());
return finacialExpenseMapper.insertFinacialExpense(finacialExpense);
}
/**
* 修改报销管理
*
* @param finacialExpense 报销管理
* @return 结果
*/
@Override
public int updateFinacialExpense(FinacialExpense finacialExpense)
{
String loginName = ShiroUtils.getLoginName();
finacialExpense.setUpdateBy(loginName);
finacialExpense.setUpdateTime(DateUtils.getNowDate());
return finacialExpenseMapper.updateFinacialExpense(finacialExpense);
}
/**
* 删除报销管理对象
*
* @param ids 需要删除的数据ID
* @return 结果
*/
@Override
public int deleteFinacialExpenseByIds(String ids)
{
return finacialExpenseMapper.deleteFinacialExpenseByIds(Convert.toStrArray(ids));
}
/**
* 删除报销管理信息
*
* @param expenseId 报销管理ID
* @return 结果
*/
@Override
public int deleteFinacialExpenseById(Long expenseId)
{
return finacialExpenseMapper.deleteFinacialExpenseById(expenseId);
}
/**
* 作废报销管理
*
* @param expenseId 报销管理ID
* @return 结果
*/
@Override
public int cancelFinacialExpenseById(Long expenseId)
{
return finacialExpenseMapper.cancelFinacialExpenseById(expenseId);
}
/**
* 恢复报销管理信息
*
* @param expenseId 报销管理ID
* @return 结果
*/
@Override
public int restoreFinacialExpenseById(Long expenseId)
{
return finacialExpenseMapper.restoreFinacialExpenseById(expenseId);
}
}

417
ruoyi-admin/src/main/java/com/ruoyi/financial/service/impl/FinancialExpenseServiceImpl.java

@ -0,0 +1,417 @@
package com.ruoyi.financial.service.impl;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
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.utils.DateUtils;
import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.financial.domain.FinacialExpense;
import com.ruoyi.financial.domain.VO.FinacialExpenseVo;
import com.ruoyi.financial.mapper.FinacialExpenseMapper;
import com.ruoyi.financial.service.IFinacialExpenseService;
import com.ruoyi.financial.service.impl.FinacialExpenseChild;
import com.ruoyi.process.general.service.IProcessService;
import com.ruoyi.process.todoitem.mapper.BizTodoItemMapper;
import com.ruoyi.system.domain.Vo.BaseExpenseAccountVo;
import com.ruoyi.system.mapper.SysUserMapper;
import com.ruoyi.system.service.ISysRoleService;
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 com.ruoyi.common.core.text.Convert;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
/**
* 报销单Service业务层处理
*
* @author zhang
* @date 2024-05-20
*/
@Service
public class FinancialExpenseServiceImpl implements IFinacialExpenseService
{
@Autowired
private FinacialExpenseMapper finacialExpenseMapper;
@Autowired
private RedisCache redisCache;
@Autowired
private SysUserMapper userMapper;
@Autowired
private TaskService taskService;
@Autowired
private BizTodoItemMapper todoItemMapper;
@Autowired
private IProcessService processService;
@Autowired
private ISysRoleService roleService;
/**
* 查询报销单
*
* @param expenseId 报销单ID
* @return 报销单
*/
@Override
public FinacialExpenseVo selectFinacialExpenseById(Long expenseId)
{
FinacialExpenseVo finacialExpenseVo = finacialExpenseMapper.selectFinacialExpenseById(expenseId);
SysUser sysUser2 = userMapper.selectUserByLoginName(finacialExpenseVo.getApplyUser());
if (sysUser2!=null){
finacialExpenseVo.setApplyUserName(sysUser2.getUserName());
}
return finacialExpenseVo;
}
@Override
public List<FinacialExpense> selectFinacialExpenseList(FinacialExpense finacialExpense) {
return finacialExpenseMapper.selectFinacialExpenseList(finacialExpense);
}
/**
* 查询报销单列表
*
* @param finacialExpense 报销单
* @return 报销单
*/
@Override
public List<FinacialExpenseVo> selectFinacialExpenseList(FinacialExpenseVo finacialExpense)
{
PageDomain pageDomain = TableSupport.buildPageRequest();
Integer pageNum = pageDomain.getPageNum();
Integer pageSize = pageDomain.getPageSize();
PageHelper.startPage(pageNum, pageSize);
//PageHelper 仅对第一List分页有效
Page<FinacialExpenseVo> list = (Page<FinacialExpenseVo>) selectFinacialExpenseList(finacialExpense);
Page<FinacialExpenseVo> returnList = new Page<>();
for(FinacialExpenseVo finacialExpenseVo : list){
SysUser sysUser = userMapper.selectUserByLoginName(finacialExpenseVo.getCreateBy());
if (sysUser != null) {
finacialExpenseVo.setCreateBy(sysUser.getUserName());
}
SysUser sysUser2 = userMapper.selectUserByLoginName(finacialExpenseVo.getApplyUser());
if (sysUser2!=null){
finacialExpenseVo.setApplyUserName(sysUser2.getUserName());
}
String instanceId = finacialExpenseVo.getInstanceId();
// 当前环节
if (StringUtils.isNotBlank(instanceId)) {
List<Task> taskList = taskService.createTaskQuery()
.processInstanceId(instanceId)
// .singleResult();
.list(); // 例如请假会签,会同时拥有多个任务
if (!CollectionUtils.isEmpty(taskList)) {
TaskEntityImpl task = (TaskEntityImpl) taskList.get(0);
String taskId = task.getId();
finacialExpenseVo.setTaskId(taskId);
// 设置待办用户
List<String> todoUserList = todoItemMapper.selectUndealTodoUserList(taskId);
if(!CollectionUtils.isEmpty(taskList)){
finacialExpenseVo.setTodoUserId(String.join(",",todoUserList));
}
if (task.getSuspensionState() == 2) {
finacialExpenseVo.setTaskName("已挂起");
finacialExpenseVo.setSuspendState("2");
} else {
finacialExpenseVo.setTaskName(task.getName());
finacialExpenseVo.setSuspendState("1");
}
} else {
// 已办结或者已撤销
finacialExpenseVo.setTaskName("已结束");
}
} else {
finacialExpenseVo.setTaskName("未启动");
}
returnList.add(finacialExpenseVo);
}
returnList.setTotal(CollectionUtils.isEmpty(list) ? 0 : list.getTotal());
returnList.setPageNum(pageNum);
returnList.setPageSize(pageSize);
return returnList;
}
/**
* 新增报销单
*
* @param finacialExpense 报销单
* @return 结果
*/
@Override
public int insertFinacialExpense(FinacialExpense finacialExpense)
{
String loginName = ShiroUtils.getLoginName();
finacialExpense.setCreateBy(loginName);
finacialExpense.setCreateTime(DateUtils.getNowDate());
finacialExpense.setDelFlag("0");
// finacialExpense.setExpenseCode(redisCache.generateBillNo("BX"));
// List<FinacialExpenseChild> finacialExpenseChildList = finacialExpense.getExpenseAccountChildList();
// if (!CollectionUtils.isEmpty(finacialExpenseChildList)) {
// for (FinacialExpenseChild finacialExpenseChild :finacialExpenseChildList) {
// finacialExpenseChild.setCreateBy(loginName);
// finacialExpenseChild.setCreateTime(DateUtils.getNowDate());
// //获取父表的单号
// finacialExpenseChild.setExpenseCode(finacialExpense.getExpenseCode());
// finacialExpenseChildService.insertFinacialExpenseChild(finacialExpenseChild);
// }
// }
return finacialExpenseMapper.insertFinacialExpense(finacialExpense);
}
/**
* 修改报销单 暂时去掉子表数据后续添加
*
* @param finacialExpense 报销单
* @return 结果
*/
@Override
public int updateFinacialExpense(FinacialExpense finacialExpense)
{
String loginName = ShiroUtils.getLoginName();
finacialExpense.setUpdateBy(loginName);
finacialExpense.setUpdateTime(DateUtils.getNowDate());
finacialExpense.setDelFlag("0");
// List<FinacialExpenseChild> finacialExpenseChildList = finacialExpense.getExpenseAccountChildList();
// if (!CollectionUtils.isEmpty(finacialExpenseChildList)) {
// finacialExpenseChildService.deleteFinacialExpenseChildByExpenseCode(finacialExpense.getExpenseCode());
// for (FinacialExpenseChild finacialExpenseChild :finacialExpenseChildList) {
// finacialExpenseChild.setCreateBy(loginName);
// finacialExpenseChild.setCreateTime(DateUtils.getNowDate());
// //获取父表的单号
// finacialExpenseChild.setExpenseCode(finacialExpense.getExpenseCode());
// finacialExpenseChildService.insertFinacialExpenseChild(finacialExpenseChild);
// }
// }
return finacialExpenseMapper.updateFinacialExpense(finacialExpense);
}
/**
* 删除报销单对象
*
* @param ids 需要删除的数据ID
* @return 结果
*/
@Override
public int deleteFinacialExpenseByIds(String ids)
{
return finacialExpenseMapper.deleteFinacialExpenseByIds(Convert.toStrArray(ids));
}
/**
* 删除报销单信息
*
* @param expenseId 报销单ID
* @return 结果
*/
@Override
public int deleteFinacialExpenseById(Long expenseId)
{
return finacialExpenseMapper.deleteFinacialExpenseById(expenseId);
}
/**
* 作废报销单
*
* @param expenseId 报销单ID
* @return 结果
*/
@Override
public int cancelFinacialExpenseById(Long expenseId)
{
return finacialExpenseMapper.cancelFinacialExpenseById(expenseId);
}
/**
* 恢复报销单信息
*
* @param expenseId 报销单ID
* @return 结果
*/
@Override
public int restoreFinacialExpenseById(Long expenseId)
{
return finacialExpenseMapper.restoreFinacialExpenseById(expenseId);
}
@Override
@Transactional(rollbackFor = Exception.class)
public ProcessInstance cancelSysCustomerById(Long id) {
FinacialExpenseVo finacialExpenseVo = finacialExpenseMapper.selectFinacialExpenseById(id);
// 审核状态-待审核
finacialExpenseVo.setAuditStatus("0");
SysUser user = ShiroUtils.getSysUser();
// 启动流程
String applyTitle = user.getUserName()+"发起了客户信息作废审批-"+ DateUtils.dateTimeNow();
String instanceType = "cancel";
FinacialExpense finacialExpense = new FinacialExpense();
BeanUtils.copyProperties(finacialExpenseVo,finacialExpense);
ProcessInstance processInstance = startProcessInstance(applyTitle,instanceType,finacialExpense, user);
String processInstanceId = processInstance.getProcessInstanceId();
// 作废实例id
finacialExpense.setCancelInstanceId(processInstanceId);
// 存在提交完就流程结束的情况
boolean processIsFinish = processService.judgeProcessIsFinish(processInstanceId);
if(processIsFinish){
// 审核状态-审核通过
finacialExpense.setAuditStatus("1");
// 使用状态-已作废
finacialExpense.setUseStatus("2");
}
finacialExpenseMapper.updateFinacialExpense(finacialExpense);
return processInstance;
}
@Override
@Transactional(rollbackFor = Exception.class)
public ProcessInstance restoreSysCustomerById(Long id) {
FinacialExpenseVo finacialExpenseVo = finacialExpenseMapper.selectFinacialExpenseById(id);
// 审核状态-待审核
finacialExpenseVo.setAuditStatus("0");
SysUser user = ShiroUtils.getSysUser();
// 启动流程
String applyTitle = user.getUserName()+"发起了客户恢复审批-"+DateUtils.dateTimeNow();
String instanceType = "restore";
FinacialExpense finacialExpense = new FinacialExpense();
BeanUtils.copyProperties(finacialExpenseVo,finacialExpense);
ProcessInstance processInstance = startProcessInstance(applyTitle,instanceType,finacialExpense, user);
String processInstanceId = processInstance.getProcessInstanceId();
// 恢复实例id
finacialExpense.setRestoreInstanceId(processInstanceId);
// 存在提交完就流程结束的情况
boolean processIsFinish = processService.judgeProcessIsFinish(processInstanceId);
if(processIsFinish){
// 审核状态-审核通过
finacialExpense.setAuditStatus("1");
// 使用状态-是
finacialExpense.setUseStatus("1");
}
finacialExpenseMapper.updateFinacialExpense(finacialExpense);
return processInstance;
}
/**
* 提交申请
* @param finacialExpense
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public ProcessInstance submitApply(FinacialExpense finacialExpense) {
SysUser user = ShiroUtils.getSysUser();
finacialExpense.setApplyUser(user.getLoginName());
finacialExpense.setApplyTime(DateUtils.getNowDate());
insertFinacialExpense(finacialExpense);
if (finacialExpense.getExpenseId() == null || finacialExpense.getExpenseId() == 0){
insertFinacialExpense(finacialExpense);
}
// 启动流程
String applyTitle = user.getUserName()+"发起了报销管理提交审批-"+DateUtils.dateTimeNow();
String instanceType = "submit";
ProcessInstance processInstance = startProcessInstance(applyTitle,instanceType,finacialExpense, user);
String processInstanceId = processInstance.getProcessInstanceId();
// 提交实例id
finacialExpense.setSubmitInstanceId(processInstanceId);
// 存在提交完就流程结束的情况
boolean processIsFinish = processService.judgeProcessIsFinish(processInstanceId);
if(processIsFinish){
// 审核状态-审核通过
finacialExpense.setAuditStatus("1");
// 使用状态-是
finacialExpense.setUseStatus("1");
//设置财务审核状态
finacialExpense.setFinanceAuditStatus("1");
}
finacialExpenseMapper.updateFinacialExpense(finacialExpense);
return processInstance;
}
private ProcessInstance startProcessInstance(String applyTitle, String instanceType, FinacialExpense finacialExpense, SysUser user) {
Long expenseId = finacialExpense.getExpenseId();
String businessKey = expenseId.toString(); // 实体类 ID,作为流程的业务 key
String key = "expense";
Map<String,Object> variables = new HashMap<>();
// 构造authority传参
buildAuthority(user, variables);
finacialExpense.setApplyTitle(applyTitle);
// 启动流程
ProcessInstance processInstance = processService.submitApply(user.getLoginName(), businessKey, applyTitle,
finacialExpense.getExpenseCode(), key, variables);
String processInstanceId = processInstance.getId();
finacialExpense.setInstanceId(processInstanceId); // 建立双向关系
finacialExpense.setInstanceType(instanceType);
return processInstance;
}
private void buildAuthority(SysUser user, Map<String, Object> variables) {
Set<String> roleKeys = roleService.selectRoleKeys(user.getUserId());
variables.put("authority",1);
//判断请购人的角色,进入相应的逻辑,设置节点审批人变量
}
@Override
public Object getId() {
return redisCache.generateBillNo("BX");
}
@Override
public int insertFinacialExpense(BaseExpenseAccountVo baseExpenseAccountVo) {
return 0;
}
public ProcessInstance submitApply(BaseExpenseAccountVo baseExpenseAccountVo) {
//将对应的baseExpense数据插入到finacial_expense表
FinacialExpense finacialExpense = new FinacialExpense();
BeanUtils.copyProperties(baseExpenseAccountVo,finacialExpense);
finacialExpense.setFinanceAuditStatus("1");
SysUser user = ShiroUtils.getSysUser();
finacialExpense.setApplyUser(user.getLoginName());
finacialExpense.setApplyTime(DateUtils.getNowDate());
insertFinacialExpense(finacialExpense);
if (finacialExpense.getExpenseId() == null || finacialExpense.getExpenseId() == 0){
insertFinacialExpense(finacialExpense);
}
// 启动流程
String applyTitle = user.getUserName()+"发起了报销管理提交审批-"+DateUtils.dateTimeNow();
String instanceType = "submit";
ProcessInstance processInstance = startProcessInstance(applyTitle,instanceType,finacialExpense, user);
String processInstanceId = processInstance.getProcessInstanceId();
// 提交实例id
finacialExpense.setSubmitInstanceId(processInstanceId);
// 存在提交完就流程结束的情况
boolean processIsFinish = processService.judgeProcessIsFinish(processInstanceId);
if(processIsFinish){
// 审核状态-审核通过
finacialExpense.setAuditStatus("1");
// 使用状态-是
finacialExpense.setUseStatus("1");
//设置财务审核状态
finacialExpense.setFinanceAuditStatus("1");
}
finacialExpenseMapper.updateFinacialExpense(finacialExpense);
return processInstance;
}
}

144
ruoyi-admin/src/main/resources/mapper/financial/FinacialExpenseMapper.xml

@ -4,7 +4,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.financial.mapper.FinacialExpenseMapper"> <mapper namespace="com.ruoyi.financial.mapper.FinacialExpenseMapper">
<resultMap type="FinacialExpense" id="FinacialExpenseResult"> <resultMap type="FinacialExpenseVo" id="FinacialExpenseResult">
<result property="expenseId" column="expense_id" /> <result property="expenseId" column="expense_id" />
<result property="auditStatus" column="audit_status" /> <result property="auditStatus" column="audit_status" />
<result property="managerAuditStatus" column="manager_audit_status" /> <result property="managerAuditStatus" column="manager_audit_status" />
@ -26,32 +26,76 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateTime" column="update_time" /> <result property="updateTime" column="update_time" />
<result property="remark" column="remark" /> <result property="remark" column="remark" />
<result property="useStatus" column="use_status" /> <result property="useStatus" column="use_status" />
<result property="instanceId" column="instance_id" />
<result property="instanceType" column="instance_type" />
<result property="instanceTypeName" column="instance_type_name" />
<result property="submitInstanceId" column="submit_instance_id" />
<result property="cancelInstanceId" column="cancel_instance_id" />
<result property="restoreInstanceId" column="restore_instance_id" />
<result property="applyTitle" column="apply_title" />
<result property="applyUser" column="apply_user" />
<result property="applyTime" column="apply_time" />
<result property="delFlag" column="del_flag" /> <result property="delFlag" column="del_flag" />
</resultMap> </resultMap>
<sql id="selectFinacialExpenseVo"> <sql id="selectFinacialExpenseVo">
select expense_id, audit_status, manager_audit_status, finance_audit_status, expense_code, deptName, postName, fullName, expense_method, is_purchase_outsource, supplier_code, corporate_payee, corporate_receiving_account, public_account_banks, apply_user, create_by, create_time, update_by, update_time, remark, use_status, del_flag from finacial_expense select expense_id, audit_status, manager_audit_status,
finance_audit_status, expense_code, deptName, postName, fullName,
expense_method, is_purchase_outsource, supplier_code, corporate_payee,
corporate_receiving_account, public_account_banks, apply_user, create_by,
create_time, update_by, update_time, remark, use_status, del_flag
from financial_expense
</sql> </sql>
<select id="selectFinacialExpenseList" parameterType="FinacialExpense" resultMap="FinacialExpenseResult"> <select id="selectFinacialExpenseList" parameterType="FinacialExpense" resultMap="FinacialExpenseResult">
<include refid="selectFinacialExpenseVo"/> select b.expense_id, b.audit_status, b.manager_audit_status, b.finance_audit_status,
b.expense_code, b.deptName, b.postName, b.fullName, b.expense_method, b.is_purchase_outsource,
b.supplier_code, b.corporate_payee, b.corporate_receiving_account, b.public_account_banks,
b.apply_user, b.create_by, b.create_time, b.update_by, b.update_time, b.remark, b.use_status, b.del_flag,
b.instance_id, b.instance_type, p.dict_value as instance_type_name, b.submit_instance_id, b.cancel_instance_id, b.restore_instance_id,
b.apply_title, b.apply_user, b.apply_time
from financial_expense as b
left join (
select dict_value, dict_label from sys_dict_data where dict_type = 'processType'
) as p
on b.instance_type = p.dict_value
<where>
<if test="auditStatus != null and auditStatus != ''"> and b.audit_status = #{auditStatus}</if>
<if test="managerAuditStatus != null and managerAuditStatus != ''"> and b.manager_audit_status = #{managerAuditStatus}</if>
<if test="financeAuditStatus != null and financeAuditStatus != ''"> and b.finance_audit_status = #{financeAuditStatus}</if>
<if test="expenseCode != null and expenseCode != ''"> and b.expense_code = #{expenseCode}</if>
<if test="expenseMethod != null and expenseMethod != ''"> and b.expense_method = #{expenseMethod}</if>
<if test="useStatus != null and useStatus != ''"> and b.use_status = #{useStatus}</if>
<if test="instanceId != null and instanceId != ''"> and b.instance_id = #{instanceId}</if>
<if test="instanceType != null and instanceType != ''"> and b.instance_type = #{instanceType}</if>
<if test="submitInstanceId != null and submitInstanceId != ''"> and b.submit_instance_id = #{submitInstanceId}</if>
<if test="cancelInstanceId != null and cancelInstanceId != ''"> and b.cancel_instance_id = #{cancelInstanceId}</if>
<if test="restoreInstanceId != null and restoreInstanceId != ''"> and b.restore_instance_id = #{restoreInstanceId}</if>
<if test="applyTitle != null and applyTitle != ''"> and b.apply_title = #{applyTitle}</if>
<if test="applyUser != null and applyUser != ''"> and b.apply_user = #{applyUser}</if>
<if test="applyTime != null "> and b.apply_time = #{applyTime}</if>
<if test="keyword != null and keyword != ''"> and b.expense_code like concat('%',#{keyword},'%')</if>
<if test="params.beginCreateTime != null and params.endCreateTime != null and params.endCreateTime != ''">
and b.create_time between #{params.beginCreateTime} and #{params.endCreateTime}
</if>
<if test="(params.costType != null and params.costType != '')
or (params.evectionCode != null and params.evectionCode != '')
or (params.costSmallType != null and params.costSmallType != '')
or (params.outsourceCode != null and params.outsourceCode != '')
or (params.purchaseCode != null and params.purchaseCode != '')">
and b.expense_code in (
select expense_code from financial_expense_child
<where> <where>
<if test="auditStatus != null and auditStatus != ''"> and audit_status = #{auditStatus}</if> <if test="params.costType != null and params.costType != ''">and cost_type = #{params.costType}</if>
<if test="managerAuditStatus != null and managerAuditStatus != ''"> and manager_audit_status = #{managerAuditStatus}</if> <if test="params.costSmallType != null and params.costSmallType != ''">and cost_small_type = #{params.costSmallType}</if>
<if test="financeAuditStatus != null and financeAuditStatus != ''"> and finance_audit_status = #{financeAuditStatus}</if> <if test="params.evectionCode != null and params.evectionCode != ''">and evection_code like concat('%',#{params.evectionCode},'%')</if>
<if test="expenseCode != null and expenseCode != ''"> and expense_code = #{expenseCode}</if> <if test="params.outsourceCode != null and params.outsourceCode != ''">and outsource_code like concat('%',#{params.outsourceCode},'%')</if>
<if test="deptName != null and deptName != ''"> and deptName like concat('%', #{deptName}, '%')</if> <if test="params.purchaseCode != null and params.purchaseCode != ''">and purchase_code like concat('%',#{params.purchaseCode},'%')</if>
<if test="postName != null and postName != ''"> and postName like concat('%', #{postName}, '%')</if>
<if test="fullName != null and fullName != ''"> and fullName like concat('%', #{fullName}, '%')</if>
<if test="expenseMethod != null and expenseMethod != ''"> and expense_method = #{expenseMethod}</if>
<if test="isPurchaseOutsource != null and isPurchaseOutsource != ''"> and is_purchase_outsource = #{isPurchaseOutsource}</if>
<if test="supplierCode != null and supplierCode != ''"> and supplier_code = #{supplierCode}</if>
<if test="corporatePayee != null and corporatePayee != ''"> and corporate_payee = #{corporatePayee}</if>
<if test="corporateReceivingAccount != null and corporateReceivingAccount != ''"> and corporate_receiving_account = #{corporateReceivingAccount}</if>
<if test="publicAccountBanks != null and publicAccountBanks != ''"> and public_account_banks = #{publicAccountBanks}</if>
<if test="applyUser != null and applyUser != ''"> and apply_user = #{applyUser}</if>
<if test="useStatus != null and useStatus != ''"> and use_status = #{useStatus}</if>
</where> </where>
)
</if>
</where>
order by b.audit_status desc, b.create_time asc
</select> </select>
<select id="selectFinacialExpenseById" parameterType="Long" resultMap="FinacialExpenseResult"> <select id="selectFinacialExpenseById" parameterType="Long" resultMap="FinacialExpenseResult">
@ -60,7 +104,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select> </select>
<insert id="insertFinacialExpense" parameterType="FinacialExpense" useGeneratedKeys="true" keyProperty="expenseId"> <insert id="insertFinacialExpense" parameterType="FinacialExpense" useGeneratedKeys="true" keyProperty="expenseId">
insert into finacial_expense insert into financial_expense
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
<if test="auditStatus != null">audit_status,</if> <if test="auditStatus != null">audit_status,</if>
<if test="managerAuditStatus != null">manager_audit_status,</if> <if test="managerAuditStatus != null">manager_audit_status,</if>
@ -75,13 +119,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="corporatePayee != null">corporate_payee,</if> <if test="corporatePayee != null">corporate_payee,</if>
<if test="corporateReceivingAccount != null">corporate_receiving_account,</if> <if test="corporateReceivingAccount != null">corporate_receiving_account,</if>
<if test="publicAccountBanks != null">public_account_banks,</if> <if test="publicAccountBanks != null">public_account_banks,</if>
<if test="applyUser != null">apply_user,</if>
<if test="createBy != null">create_by,</if> <if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if> <if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="remark != null">remark,</if> <if test="remark != null">remark,</if>
<if test="useStatus != null">use_status,</if> <if test="useStatus != null">use_status,</if>
<if test="instanceId != null">instance_id,</if>
<if test="instanceType != null">instance_type,</if>
<if test="submitInstanceId != null">submit_instance_id,</if>
<if test="cancelInstanceId != null">cancel_instance_id,</if>
<if test="restoreInstanceId != null">restore_instance_id,</if>
<if test="applyTitle != null">apply_title,</if>
<if test="applyUser != null">apply_user,</if>
<if test="applyTime != null">apply_time,</if>
<if test="delFlag != null">del_flag,</if> <if test="delFlag != null">del_flag,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
@ -98,19 +147,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="corporatePayee != null">#{corporatePayee},</if> <if test="corporatePayee != null">#{corporatePayee},</if>
<if test="corporateReceivingAccount != null">#{corporateReceivingAccount},</if> <if test="corporateReceivingAccount != null">#{corporateReceivingAccount},</if>
<if test="publicAccountBanks != null">#{publicAccountBanks},</if> <if test="publicAccountBanks != null">#{publicAccountBanks},</if>
<if test="applyUser != null">#{applyUser},</if>
<if test="createBy != null">#{createBy},</if> <if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if> <if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if> <if test="remark != null">#{remark},</if>
<if test="useStatus != null">#{useStatus},</if> <if test="useStatus != null">#{useStatus},</if>
<if test="instanceId != null">#{instanceId},</if>
<if test="instanceType != null">#{instanceType},</if>
<if test="submitInstanceId != null">#{submitInstanceId},</if>
<if test="cancelInstanceId != null">#{cancelInstanceId},</if>
<if test="restoreInstanceId != null">#{restoreInstanceId},</if>
<if test="applyTitle != null">#{applyTitle},</if>
<if test="applyUser != null">#{applyUser},</if>
<if test="applyTime != null">#{applyTime},</if>
<if test="delFlag != null">#{delFlag},</if> <if test="delFlag != null">#{delFlag},</if>
</trim> </trim>
</insert> </insert>
<update id="updateFinacialExpense" parameterType="FinacialExpense"> <update id="updateFinacialExpense" parameterType="FinacialExpense">
update finacial_expense update financial_expense
<trim prefix="SET" suffixOverrides=","> <trim prefix="SET" suffixOverrides=",">
<if test="auditStatus != null">audit_status = #{auditStatus},</if> <if test="auditStatus != null">audit_status = #{auditStatus},</if>
<if test="managerAuditStatus != null">manager_audit_status = #{managerAuditStatus},</if> <if test="managerAuditStatus != null">manager_audit_status = #{managerAuditStatus},</if>
@ -125,35 +179,57 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="corporatePayee != null">corporate_payee = #{corporatePayee},</if> <if test="corporatePayee != null">corporate_payee = #{corporatePayee},</if>
<if test="corporateReceivingAccount != null">corporate_receiving_account = #{corporateReceivingAccount},</if> <if test="corporateReceivingAccount != null">corporate_receiving_account = #{corporateReceivingAccount},</if>
<if test="publicAccountBanks != null">public_account_banks = #{publicAccountBanks},</if> <if test="publicAccountBanks != null">public_account_banks = #{publicAccountBanks},</if>
<if test="applyUser != null">apply_user = #{applyUser},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if> <if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if> <if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if> <if test="remark != null">remark = #{remark},</if>
<if test="useStatus != null">use_status = #{useStatus},</if> <if test="useStatus != null">use_status = #{useStatus},</if>
<if test="instanceId != null">instance_id = #{instanceId},</if>
<if test="instanceType != null">instance_type = #{instanceType},</if>
<if test="submitInstanceId != null">submit_instance_id = #{submitInstanceId},</if>
<if test="cancelInstanceId != null">cancel_instance_id = #{cancelInstanceId},</if>
<if test="restoreInstanceId != null">restore_instance_id = #{restoreInstanceId},</if>
<if test="applyTitle != null">apply_title = #{applyTitle},</if>
<if test="applyUser != null">apply_user = #{applyUser},</if>
<if test="applyTime != null">apply_time = #{applyTime},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if> <if test="delFlag != null">del_flag = #{delFlag},</if>
</trim> </trim>
where expense_id = #{expenseId} where expense_id = #{expenseId}
</update> </update>
<delete id="deleteFinacialExpenseById" parameterType="Long"> <delete id="deleteFinacialExpenseById" parameterType="Long">
delete from finacial_expense where expense_id = #{expenseId} delete from financial_expense where expense_id = #{expenseId}
</delete> </delete>
<delete id="deleteFinacialExpenseByIds" parameterType="String"> <delete id="deleteFinacialExpenseByIds" parameterType="String">
delete from finacial_expense where expense_id in delete from financial_expense where expense_id in
<foreach item="expenseId" collection="array" open="(" separator="," close=")"> <foreach item="expenseId" collection="array" open="(" separator="," close=")">
#{expenseId} #{expenseId}
</foreach> </foreach>
</delete> </delete>
<delete id="deleteFinacialeByExpenseCode" parameterType="String">
delete from financial_expense where expense_code = #{expenseCode}
</delete>
<delete id="deleteFinacialByExpenseCodes" parameterType="String">
delete from financial_expense where expense_code in
<foreach item="expenseId" collection="array" open="(" separator="," close=")">
#{expenseCode}
</foreach>
</delete>
<update id="cancelFinacialExpenseById" parameterType="Long"> <update id="cancelFinacialExpenseById" parameterType="Long">
update finacial_expense set del_flag = '1' where expense_id = #{expenseId} update financial_expense set del_flag = '1' where expense_id = #{expenseId}
</update> </update>
<update id="restoreFinacialExpenseById" parameterType="Long"> <update id="restoreFinacialExpenseById" parameterType="Long">
update finacial_expense set del_flag = '0' where expense_id = #{expenseId} update financial_expense set del_flag = '0' where expense_id = #{expenseId}
</update>
<update id="deleteExpenseFlagByExpenseCodes" parameterType="String">
update financial_expense set del_flag = '1' where expense_code in
<foreach item="expenseCode" collection="array" open="(" separator="," close=")">
#{expenseCode}
</foreach>
</update> </update>
<update id="deleteExpenseFlagByExpenseCode" parameterType="String">
update financial_expense set del_flag = '1' where expense_code = #{expenseCode}
</update>
</mapper> </mapper>

176
ruoyi-admin/src/main/resources/templates/financial/expense/expense.html

@ -16,17 +16,19 @@
</li> </li>
<li> <li>
<label>报销人:</label> <label>报销人:</label>
<select name="applyUser" > <select name="applyUser"></select>
<option value="">所有</option>
</select>
</li> </li>
<li> <li>
<label>生产单号:</label> <label>出差单号:</label>
<input name="expenseCode" type="text"/> <input name="params[evectionCode]" type="text"/>
</li> </li>
<li> <li>
<label>出差单号:</label> <label>采购单号:</label>
<input name="expenseCode" type="text"/> <input name="params[purchaseCode]" type="text"/>
</li>
<li>
<label>委外单号:</label>
<input name="params[outsourceCode]" type="text"/>
</li> </li>
<li> <li>
<label>上级审核状态:</label> <label>上级审核状态:</label>
@ -54,14 +56,14 @@
</li> </li>
<li> <li>
<label>成本类型:</label> <label>成本类型:</label>
<select name="costType" th:with="childList=${@category.getChildByCode('costType')}"> <select id="costType" name="params.costType" th:with="childList=${@category.getChildByCode('costType')}" onchange="onCostTypeChange(this)">
<option value="">所有</option> <option value="">所有</option>
<option th:each="chilld: ${childList}" th:value="${chilld.code}" th:text="${chilld.name}"></option> <option th:each="chilld: ${childList}" th:value="${chilld.code}" th:text="${chilld.name}"></option>
</select> </select>
</li> </li>
<li> <li>
<label>成本小类:</label> <label>成本小类:</label>
<select name="costSamllType"> <select id="costSmallType" name="params.costSamllType">
<option value="">所有</option> <option value="">所有</option>
</select> </select>
</li> </li>
@ -89,22 +91,30 @@
</div> </div>
<div class="btn-group-sm" id="toolbar" role="group"> <div class="btn-group-sm" id="toolbar" role="group">
<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:baseExpense:add">
<i class="fa fa-plus"></i> 添加
</a>
</div> </div>
<div class="col-sm-12 select-table table-striped"> <div class="col-sm-12 select-table table-striped">
<table id="bootstrap-table"></table> <table id="bootstrap-table" style="white-space: nowrap"></table>
</div> </div>
</div> </div>
</div> </div>
<th:block th:include="include :: footer" /> <th:block th:include="include :: footer" />
<th:block th:include="include :: bootstrap-table-editable-js" />
<script th:src="@{/js/activiti.js}"></script>
<script th:inline="javascript"> <script th:inline="javascript">
var costTypeDatas = [[${@category.getChildByCode('costType')}]]; var costTypeDatas = [[${@category.getChildByCode('costType')}]];
var editFlag = [[${@permission.hasPermi('system:baseExpense:edit')}]]; var editFlag = [[${@permission.hasPermi('system:baseExpense:edit')}]];
var removeFlag = [[${@permission.hasPermi('system:baseExpense:remove')}]]; var removeFlag = [[${@permission.hasPermi('system:baseExpense:remove')}]];
var cancelFlag = [[${@permission.hasPermi('system:baseExpense:cancel')}]]; var cancelFlag = [[${@permission.hasPermi('system:baseExpense:cancel')}]];
var restoreFlag = [[${@permission.hasPermi('system:baseExpense:restore')}]]; var restoreFlag = [[${@permission.hasPermi('system:baseExpense:restore')}]];
var loginName = [[${@permission.getPrincipalProperty('loginName')}]];
var auditStatusData = [[${@dict.getType('auditStatus')}]];
var expenseMethodData = [[${@dict.getType('sys_base_expense_method')}]];
var prefix = ctx + "system/baseExpense"; var prefix = ctx + "system/baseExpense";
$(function() { $(function() {
var costTypeDatas = [[${@category.getChildByCode('costType')}]];
var options = { var options = {
url: prefix + "/list", url: prefix + "/list",
createUrl: prefix + "/add", createUrl: prefix + "/add",
@ -113,40 +123,140 @@
cancelUrl: prefix + "/cancel/{id}", cancelUrl: prefix + "/cancel/{id}",
restoreUrl: prefix + "/restore/{id}", restoreUrl: prefix + "/restore/{id}",
exportUrl: prefix + "/export", exportUrl: prefix + "/export",
detailUrl: prefix + "/detail/{id}",
modalName: "报销单", modalName: "报销单",
pageSize: 10,
sortable: true, // 是否启用排序
sortStable: true, // 设置为 true 将获得稳定的排序
// fixedColumns: true, // 启用冻结列
// rightFixedColumns:1,
// fixedNumber: 1,
// fixedRightNumber: 1, // 冻结右列个数
columns: [ columns: [
{checkbox: true}, {checkbox: true},
{title: '报销单索引id',field: 'expenseId',visible: false}, {title: '报销单索引id',field: 'expenseId',visible: false,align: 'center',},
{title: '上级审核状态',field: 'auditStatus',}, {title: '流程实例ID',field: 'instanceId',visible: false,align: 'center',},
{title: '总经理审核状态',field: 'managerAuditStatus',}, {title: '流程提交实例ID',field: 'submitInstanceId',visible: false,align: 'center',},
{title: '财务审核状态',field: 'financeAuditStatus',}, {title:'流程作废实例ID',field: 'cancelInstanceId',visible: false,align: 'center',},
{title: '报销单编号',field: 'expenseCode',}, {title: '流程恢复实例ID',field: 'restoreInstanceId', visible: false,align: 'center',},
{title: '报销人',field: 'applyUser',}, {title: '流程实例类型', field: 'instanceTypeName',visible: false,align: 'center',},
{title: '报销方式',field: 'expenseMethod', }, {field: 'applyUserName', title: '申请人',align: 'center',},
{title: '是否是委外/采购采销',field: 'isPurchaseOutsource',visible: false}, {field: 'applyTime',title: '申请时间',align: 'center',},
{title: '供应商ID',field: 'supplierCode',visible: false}, {title: '当前任务ID',field: 'taskId',visible: false,align: 'center',},
{title: '对公收款方',field: 'corporatePayee',visible: false}, {title: '待办用户ID',field: 'todoUserId', visible: false,align: 'center',},
{title: '对公收款账户',field: 'corporateReceivingAccount',visible: false}, {title: '当前任务名称',field: 'taskName',
{title: '对公开户行',field: 'publicAccountBanks',visible: false},
{title: '录入时间',field: 'createTime',},
{title: '更新人',field: 'updateBy'},
{title: '上次更新时间',field: 'updateTime',visible: false},
{title: '备注',field: 'remark',visible: false},
{title: '使用状态',field: 'useStatus',visible: false},
{
title: '操作',
align: 'center', align: 'center',
formatter: function(value, row, index) { formatter: function(value, row, index) {
return '<span class="badge badge-primary">' + value + '</span>';
}
},
{title: '上级审核状态',field: 'auditStatus',align: 'center',
formatter: function(value, row, index) {
return $.table.selectDictLabel(auditStatusData, value);
}
},
{title: '总经理审核状态',field: 'managerAuditStatus',align: 'center',
formatter: function(value, row, index) {
return $.table.selectDictLabel(auditStatusData, value);
}
},
{title: '财务审核状态',field: 'financeAuditStatus',align: 'center',
formatter: function(value, row, index) {
return $.table.selectDictLabel(auditStatusData, value);
}
},
{title: '报销单编号',field: 'expenseCode',align: 'center',},
{title: '报销人',field: 'applyUser',align: 'center',},
{title: '报销方式',field: 'expenseMethod', align: 'center',
formatter: function(value, row, index) {
return $.table.selectDictLabel(expenseMethodData, value);
}
},
{title: '是否是委外/采购采销',field: 'isPurchaseOutsource',align: 'center',visible: false},
{title: '供应商ID',field: 'supplierCode',align: 'center',visible: false},
{title: '对公收款方',field: 'corporatePayee',visible: false,align: 'center',},
{title: '对公收款账户',field: 'corporateReceivingAccount',visible: false,align: 'center',},
{title: '对公开户行',field: 'publicAccountBanks',visible: false,align: 'center',},
{title: '录入时间',field: 'createTime',align: 'center',},
{title: '更新人',field: 'updateBy',align: 'center',visible: false},
{title: '上次更新时间',field: 'updateTime',visible: false,align: 'center',},
{title: '备注',field: 'remark',visible: false,align: 'center',},
{title: '使用状态',field: 'useStatus',visible: false,align: 'center',},
{title: '操作',align: 'center', formatter: function (value, row, index) {
var actions = []; var actions = [];
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.expenseId + '\')"><i class="fa fa-edit"></i>编辑</a> '); if(row.auditStatus=="1" && row.useStatus=="1") {
actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.expenseId + '\')"><i class="fa fa-details"></i>详情</a> '); actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="$.operate.cancel(\'' + row.expenseId + '\')"><i class="fa fa-remove"></i> 作废</a>');
actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.expenseId + '\')"><i class="fa fa-edit"></i> 编辑</a> ');
}
// 有流程实例id
if(row.useStatus=="2" ){
actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="$.operate.restore(\'' + row.expenseId + '\')"><i class="fa fa-window-restore"></i> 恢复</a> ');
}
// 有流程实例id
if (row.instanceId) {
// 有待办人展示审批按钮,
if (row.todoUserId) {
var todoUserIdList = row.todoUserId.split(",");
if(todoUserIdList.includes(loginName)){
var nodeName = row.taskName=='驳回调整'?' 调整申请':' 审批';
actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="showVerifyDialog(\'' + prefix + '\',\'' + row.taskId + '\', \'' + row.taskName+"-"+ row.instanceTypeName +"申请" + '\')"><i class="fa fa-edit"></i> '+nodeName+'</a> ');
}
}
actions.push('<a class="btn btn-warning btn-xs" href="javascript:void(0)" onclick="showHistoryDialog(\'' + row.instanceId + '\')"><i class="fa fa-list"></i> 审批历史</a> ');
actions.push('<a class="btn btn-info btn-xs" href="javascript:void(0)" onclick="showProcessImgDialog(\'' + row.instanceId + '\')"><i class="fa fa-image"></i> 进度查看</a> ');
}
// 详情
actions.push('<a class="btn btn-primary btn-xs" href="javascript:void(0)" onclick="$.operate.detail(\'' + row.expenseId + '\')"><i class="fa fa-eye"></i> 详情</a> ');
return actions.join(''); return actions.join('');
} }
} }
] ],
rowStyle: function (row, index) {
if (row.auditStatus=="0") {
// 如果审核状态为待审核,则设置为红色
return {css:{"color":"red"}};
}
// 否则使用默认样式
return {};
}
}; };
$.table.init(options); $.table.init(options);
selectUserAll();
}); });
function onCostTypeChange(element) {
var costType = element.value;
$.ajax({
url: ctx + 'system/category/getChildCode',
type: 'post',
data: {code: costType},
async: false,
success: function (result) {
console.log(result);
costSamllTypes = result;
var selectHtml = '<option value="">所有</option>';
costSamllTypes.forEach(function (child) {
selectHtml += '<option value="' + child.code + '">' + child.name + '</option>';
});
$("#costSmallType").html(selectHtml);
}
});
}
function selectUserAll(){
$.ajax({
url: prefix + '/getExpenseUser',
type: 'post',
async: false,
success: function (result) {
userList = result.data;
var selectUser = $("select[name='applyUser']");
var selectHtml = '<option value="">所有</option>';
userList.forEach(function (user) {
selectHtml += '<option value="' + user.loginName + '">' + user.userName + '</option>';
});
selectUser.html(selectHtml);
}
});
}
</script> </script>
</body> </body>
</html> </html>
Loading…
Cancel
Save