diff --git a/ruoyi-admin/src/main/java/com/ruoyi/system/controller/BaseExpenseAccountController.java b/ruoyi-admin/src/main/java/com/ruoyi/system/controller/BaseExpenseAccountController.java index e6c67f41..f74dd565 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/system/controller/BaseExpenseAccountController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/system/controller/BaseExpenseAccountController.java @@ -5,6 +5,7 @@ import java.util.List; import com.alibaba.fastjson.JSON; import com.ruoyi.common.core.redis.RedisCache; +import com.ruoyi.common.utils.ShiroUtils; import com.ruoyi.process.general.service.IProcessService; import com.ruoyi.process.todoitem.mapper.BizTodoItemMapper; import com.ruoyi.remind.service.RemindService; @@ -119,15 +120,19 @@ public class BaseExpenseAccountController extends BaseController } /** - * 新增保存报销单 + * 新增保存报销单(暂时改成没有子表的方法) */ @RequiresPermissions("system:baseExpense:add") @Log(title = "报销单", businessType = BusinessType.INSERT) @PostMapping("/add") @ResponseBody - public AjaxResult addSave(@RequestBody BaseExpenseAccount baseExpenseAccount) + public AjaxResult addSave(BaseExpenseAccount baseExpenseAccount) { - return toAjax(baseExpenseAccountService.insertBaseExpenseAccount(baseExpenseAccount)); + baseExpenseAccount.setCreateBy(ShiroUtils.getLoginName()); + baseExpenseAccount.setUseStatus("0"); + baseExpenseAccount.setAuditStatus("0"); + baseExpenseAccountService.submitApply(baseExpenseAccount); + return AjaxResult.success(); } /** @@ -182,9 +187,9 @@ public class BaseExpenseAccountController extends BaseController return prefix + "/task" + verifyName; } @ModelAttribute("/preloadObj") - public BaseExpenseAccountVo getObj(@RequestParam(value = "id", required = false) Long id, HttpSession session) { - if (id != null) { - return baseExpenseAccountService.selectBaseExpenseAccountById(id); + public BaseExpenseAccountVo getObj(@RequestParam(value = "expenseId", required = false) Long expenseId, HttpSession session) { + if (expenseId != null) { + return baseExpenseAccountService.selectBaseExpenseAccountById(expenseId); } return new BaseExpenseAccountVo(); } @@ -196,17 +201,18 @@ public class BaseExpenseAccountController extends BaseController @RequestMapping(value = "/complete/{taskId}", method = {RequestMethod.POST, RequestMethod.GET}) @ResponseBody public AjaxResult complete(@PathVariable("taskId") String taskId, @RequestParam(value = "saveEntity", required = false) String saveEntity, - @RequestParam(value = "customerQuoteChildList", required = false) String customerQuoteChildList, @ModelAttribute("preloadObj") BaseExpenseAccountVo baseExpenseAccountVo, HttpServletRequest request) { boolean saveEntityBoolean = BooleanUtils.toBoolean(saveEntity); - baseExpenseAccountVo.setExpenseAccountChildList(JSON.parseArray(customerQuoteChildList, BaseExpenseAccountChild.class)); + if (saveEntityBoolean){ + baseExpenseAccountService.updateBaseExpenseAccount(baseExpenseAccountVo); + } String instanceId = baseExpenseAccountVo.getInstanceId(); String instanceType = baseExpenseAccountVo.getInstanceType(); boolean approvedFlag = processService.complete(taskId, instanceId, baseExpenseAccountVo.getApplyTitle(), - baseExpenseAccountVo.getSupplierCode(), - "customerQuote", new HashMap(), request); + baseExpenseAccountVo.getExpenseCode(), + "expense", new HashMap(), request); if(!approvedFlag){ // 审核状态-审核拒绝 baseExpenseAccountVo.setAuditStatus("2"); @@ -216,6 +222,8 @@ public class BaseExpenseAccountController extends BaseController if (processIsFinish) { // 审核通过 baseExpenseAccountVo.setAuditStatus("1"); + baseExpenseAccountVo.setFinanceAuditStatus("1"); + baseExpenseAccountVo.setManagerAuditStatus("1"); // 提交 if("submit".equals(instanceType)){ // 使用状态-是 diff --git a/ruoyi-admin/src/main/java/com/ruoyi/system/domain/BaseExpenseAccount.java b/ruoyi-admin/src/main/java/com/ruoyi/system/domain/BaseExpenseAccount.java index 375e5961..8e79c31c 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/system/domain/BaseExpenseAccount.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/system/domain/BaseExpenseAccount.java @@ -351,6 +351,7 @@ public class BaseExpenseAccount extends BaseEntity .append("updateTime", getUpdateTime()) .append("remark", getRemark()) .append("useStatus", getUseStatus()) + .append("delFlag", getDelFlag()) .toString(); } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/BaseExpenseAccountServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/BaseExpenseAccountServiceImpl.java index baad2bbd..b6609c1d 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/BaseExpenseAccountServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/BaseExpenseAccountServiceImpl.java @@ -5,10 +5,15 @@ import java.util.List; import java.util.Map; import java.util.Set; +import com.github.pagehelper.Page; +import com.ruoyi.common.annotation.Excel; 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.process.general.service.IProcessService; import com.ruoyi.process.todoitem.mapper.BizTodoItemMapper; import com.ruoyi.system.domain.BaseExpenseAccountChild; @@ -17,7 +22,9 @@ import com.ruoyi.system.mapper.SysUserMapper; import com.ruoyi.system.service.IBaseExpenseAccountChildService; 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; @@ -26,6 +33,7 @@ import com.ruoyi.system.domain.BaseExpenseAccount; import com.ruoyi.system.service.IBaseExpenseAccountService; import com.ruoyi.common.core.text.Convert; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; /** * 报销单Service业务层处理 @@ -81,7 +89,57 @@ public class BaseExpenseAccountServiceImpl implements IBaseExpenseAccountService @Override public List selectBaseExpenseAccountList(BaseExpenseAccount baseExpenseAccount) { - return baseExpenseAccountMapper.selectBaseExpenseAccountList(baseExpenseAccount); + PageDomain pageDomain = TableSupport.buildPageRequest(); + Integer pageNum = pageDomain.getPageNum(); + Integer pageSize = pageDomain.getPageSize(); + //PageHelper 仅对第一List分页有效 + Page list = (Page) baseExpenseAccountMapper.selectBaseExpenseAccountList(baseExpenseAccount); + Page returnList = new Page<>(); + for(BaseExpenseAccountVo baseExpenseAccountVo : list){ + SysUser sysUser = userMapper.selectUserByLoginName(baseExpenseAccountVo.getCreateBy()); + if (sysUser != null) { + baseExpenseAccountVo.setCreateBy(sysUser.getUserName()); + } + SysUser sysUser2 = userMapper.selectUserByLoginName(baseExpenseAccountVo.getApplyUser()); + if (sysUser2!=null){ + baseExpenseAccountVo.setApplyUserName(sysUser2.getUserName()); + } + String instanceId = baseExpenseAccountVo.getInstanceId(); + // 当前环节 + if (StringUtils.isNotBlank(instanceId)) { + List taskList = taskService.createTaskQuery() + .processInstanceId(instanceId) +// .singleResult(); + .list(); // 例如请假会签,会同时拥有多个任务 + if (!CollectionUtils.isEmpty(taskList)) { + TaskEntityImpl task = (TaskEntityImpl) taskList.get(0); + String taskId = task.getId(); + baseExpenseAccountVo.setTaskId(taskId); + // 设置待办用户 + List todoUserList = todoItemMapper.selectUndealTodoUserList(taskId); + if(!CollectionUtils.isEmpty(taskList)){ + baseExpenseAccountVo.setTodoUserId(String.join(",",todoUserList)); + } + if (task.getSuspensionState() == 2) { + baseExpenseAccountVo.setTaskName("已挂起"); + baseExpenseAccountVo.setSuspendState("2"); + } else { + baseExpenseAccountVo.setTaskName(task.getName()); + baseExpenseAccountVo.setSuspendState("1"); + } + } else { + // 已办结或者已撤销 + baseExpenseAccountVo.setTaskName("已结束"); + } + } else { + baseExpenseAccountVo.setTaskName("未启动"); + } + returnList.add(baseExpenseAccountVo); + } + returnList.setTotal(CollectionUtils.isEmpty(list) ? 0 : list.getTotal()); + returnList.setPageNum(pageNum); + returnList.setPageSize(pageSize); + return returnList; } /** @@ -99,21 +157,22 @@ public class BaseExpenseAccountServiceImpl implements IBaseExpenseAccountService baseExpenseAccount.setAuditStatus("0"); baseExpenseAccount.setUseStatus("0"); baseExpenseAccount.setDelFlag("0"); - List baseExpenseAccountChildList = baseExpenseAccount.getExpenseAccountChildList(); - int baseExpaneseChildSize = baseExpenseAccountChildList.size(); - if (baseExpaneseChildSize > 0) { - for (BaseExpenseAccountChild baseExpenseAccountChild :baseExpenseAccountChildList) { - baseExpenseAccountChild.setCreateBy(loginName); - baseExpenseAccountChild.setCreateTime(DateUtils.getNowDate()); - //获取父表的单号 - baseExpenseAccountChild.setExpenseCode(baseExpenseAccount.getExpenseCode()); - } - } + baseExpenseAccount.setExpenseCode(redisCache.generateBillNo("BX")); +// List baseExpenseAccountChildList = baseExpenseAccount.getExpenseAccountChildList(); +// int baseExpaneseChildSize = baseExpenseAccountChildList.size(); +// if (baseExpaneseChildSize > 0) { +// for (BaseExpenseAccountChild baseExpenseAccountChild :baseExpenseAccountChildList) { +// baseExpenseAccountChild.setCreateBy(loginName); +// baseExpenseAccountChild.setCreateTime(DateUtils.getNowDate()); +// //获取父表的单号 +// baseExpenseAccountChild.setExpenseCode(baseExpenseAccount.getExpenseCode()); +// } +// } return baseExpenseAccountMapper.insertBaseExpenseAccount(baseExpenseAccount); } /** - * 修改报销单 + * 修改报销单 (暂时去掉子表数据,后续添加) * * @param baseExpenseAccount 报销单 * @return 结果 @@ -125,18 +184,18 @@ public class BaseExpenseAccountServiceImpl implements IBaseExpenseAccountService baseExpenseAccount.setUpdateBy(loginName); baseExpenseAccount.setUpdateTime(DateUtils.getNowDate()); baseExpenseAccount.setDelFlag("0"); - List baseExpenseAccountChildList = baseExpenseAccount.getExpenseAccountChildList(); - baseExpenseAccountChildService.deleteBaseExpenseAccountChildById(baseExpenseAccount.getExpenseId()); - int baseExpenseChildSize = baseExpenseAccountChildList.size(); - if (baseExpenseChildSize > 0) { - baseExpenseAccountChildService.deleteBaseExpenseAccountChildByExpenseCode(baseExpenseAccount.getExpenseCode()); - for (BaseExpenseAccountChild baseExpenseAccountChild :baseExpenseAccountChildList) { - baseExpenseAccountChild.setCreateBy(loginName); - baseExpenseAccountChild.setCreateTime(DateUtils.getNowDate()); - //获取父表的单号 - baseExpenseAccountChild.setExpenseCode(baseExpenseAccount.getExpenseCode()); - } - } +// List baseExpenseAccountChildList = baseExpenseAccount.getExpenseAccountChildList(); +// baseExpenseAccountChildService.deleteBaseExpenseAccountChildById(baseExpenseAccount.getExpenseId()); +// int baseExpenseChildSize = baseExpenseAccountChildList.size(); +// if (baseExpenseChildSize > 0) { +// baseExpenseAccountChildService.deleteBaseExpenseAccountChildByExpenseCode(baseExpenseAccount.getExpenseCode()); +// for (BaseExpenseAccountChild baseExpenseAccountChild :baseExpenseAccountChildList) { +// baseExpenseAccountChild.setCreateBy(loginName); +// baseExpenseAccountChild.setCreateTime(DateUtils.getNowDate()); +// //获取父表的单号 +// baseExpenseAccountChild.setExpenseCode(baseExpenseAccount.getExpenseCode()); +// } +// } return baseExpenseAccountMapper.updateBaseExpenseAccount(baseExpenseAccount); } @@ -255,9 +314,11 @@ public class BaseExpenseAccountServiceImpl implements IBaseExpenseAccountService SysUser user = ShiroUtils.getSysUser(); baseExpenseAccount.setApplyUser(user.getLoginName()); baseExpenseAccount.setApplyTime(DateUtils.getNowDate()); - if (baseExpenseAccount.getExpenseId() == null || baseExpenseAccount.getExpenseId() == 0){ - insertBaseExpenseAccount(baseExpenseAccount); - } + insertBaseExpenseAccount(baseExpenseAccount); + +// if (baseExpenseAccount.getExpenseId() == null || baseExpenseAccount.getExpenseId() == 0){ +// insertBaseExpenseAccount(baseExpenseAccount); +// } // 启动流程 String applyTitle = user.getUserName()+"发起了报销单提交审批-"+DateUtils.dateTimeNow(); String instanceType = "submit"; @@ -272,6 +333,12 @@ public class BaseExpenseAccountServiceImpl implements IBaseExpenseAccountService baseExpenseAccount.setAuditStatus("1"); // 使用状态-是 baseExpenseAccount.setUseStatus("1"); + + //设置总经理审核状态 + baseExpenseAccount.setManagerAuditStatus("1"); + //设置财务审核状态 + baseExpenseAccount.setFinanceAuditStatus("1"); + } baseExpenseAccountMapper.updateBaseExpenseAccount(baseExpenseAccount); return processInstance; @@ -279,9 +346,9 @@ public class BaseExpenseAccountServiceImpl implements IBaseExpenseAccountService private ProcessInstance startProcessInstance(String applyTitle, String instanceType, BaseExpenseAccount baseExpenseAccount, SysUser user) { - Long customerId = baseExpenseAccount.getExpenseId(); - String businessKey = customerId.toString(); // 实体类 ID,作为流程的业务 key - String key = "customer"; + Long expenseId = baseExpenseAccount.getExpenseId(); + String businessKey = expenseId.toString(); // 实体类 ID,作为流程的业务 key + String key = "expense"; Map variables = new HashMap<>(); // 构造authority传参 buildAuthority(user, variables); @@ -297,15 +364,48 @@ public class BaseExpenseAccountServiceImpl implements IBaseExpenseAccountService private void buildAuthority(SysUser user, Map variables) { Set roleKeys = roleService.selectRoleKeys(user.getUserId()); - // 角色不同审核人不同 - if(roleKeys.contains("zozjRole") || roleKeys.contains("zjlRole") || roleKeys.contains("admin")){ - variables.put("authority",4); - }else if(roleKeys.contains("ywzgRole")){ - variables.put("authority",3); - }else if(roleKeys.contains("ywjlRole")){ + + variables.put("authority",1); + //判断请购人的角色,进入相应的逻辑,设置节点审批人变量 + if(roleKeys.contains("ywyRole") || roleKeys.contains("ywjlRole") || roleKeys.contains("ywzgRole")){ + // 业务经理 + variables.put("bxjlRole","ywjlRole"); + // 业务主管 + variables.put("bxzgRole","ywzgRole"); + }else if(roleKeys.contains("cgyRole") || roleKeys.contains("cgjlRole") || roleKeys.contains("cgzgRole")){ + // 采购经理 + variables.put("bxjlRole","cgjlRole"); + // 采购主管 + variables.put("bxzgRole","cgzgRole"); + }else if (roleKeys.contains("gcwyRole") || roleKeys.contains("gcjlRole") || roleKeys.contains("gczgRole")){ + // 工程经理 + variables.put("bxjlRole","gcjlRole"); + // 工程主管 + variables.put("bxzgRole","gczgRole"); + } else if (roleKeys.contains("scyRole") || roleKeys.contains("scjlRole") || roleKeys.contains("sczgRole")){ + // 生产经理 + variables.put("bxjlRole","scjlRoe"); + // 生产主管 + variables.put("bxzgRole","sczgRole"); + }else if (roleKeys.contains("shgcsRole") || roleKeys.contains("shjlRole") || roleKeys.contains("shzgRole")){ + // 售后经理 + variables.put("bxjlRole","shjlRole"); + // 售后主管 + variables.put("bxzgRole","shzgRole"); + }else if(roleKeys.contains("cgyyRole") || roleKeys.contains("ckzgRole")){ + variables.put("bxjlRole","shzgRole"); + // 售后主管 + variables.put("bxzgRole","shzgRole"); + }else if (roleKeys.contains("cwRole") || roleKeys.contains("cwjlRole")){ + variables.put("bxjlRole","cwjlRole"); + // 售后主管 + variables.put("bxzgRole","cwJlRole"); + }else{ + variables.put("authority",2); + } + if(roleKeys.contains("admin")){ + // 角色包含业务经理、采购经理、工程经理、生产经理 variables.put("authority",2); - }else if(roleKeys.contains("ywyRole")){ - variables.put("authority",1); } } @Override diff --git a/ruoyi-admin/src/main/resources/mapper/system/BaseExpenseAccountMapper.xml b/ruoyi-admin/src/main/resources/mapper/system/BaseExpenseAccountMapper.xml index 151f3427..7ef6408d 100644 --- a/ruoyi-admin/src/main/resources/mapper/system/BaseExpenseAccountMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/system/BaseExpenseAccountMapper.xml @@ -4,7 +4,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - + @@ -35,6 +35,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + @@ -42,14 +44,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" 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, - instance_id, instance_type, instance_type_name, submit_instance_id, cancel_instance_id, restore_instance_id, + instance_id, instance_type, submit_instance_id, cancel_instance_id, restore_instance_id, apply_title, apply_user, apply_time from base_expense_account + + + + + + +
+ +
+ +
+
+
+ +
+
+ + +
+
+
+
+ +
+ +
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ +
+ +
+ +
+
+ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/system/baseExpense/taskbxjlVerify.html b/ruoyi-admin/src/main/resources/templates/system/baseExpense/taskbxjlVerify.html index b495d3d5..f3f596b0 100644 --- a/ruoyi-admin/src/main/resources/templates/system/baseExpense/taskbxjlVerify.html +++ b/ruoyi-admin/src/main/resources/templates/system/baseExpense/taskbxjlVerify.html @@ -1,13 +1,13 @@ - +
-
- + + @@ -56,7 +56,7 @@
- +
@@ -102,29 +102,41 @@
- -
-
-
- 选择报销分类信息 - - 添加报销 - -
-
-
-
-
+
+ +
+
-
+ + + + + + + + + + + + + + + + +
+ \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/system/baseExpense/taskbxzgVerify.html b/ruoyi-admin/src/main/resources/templates/system/baseExpense/taskbxzgVerify.html index b0069de7..8204e04b 100644 --- a/ruoyi-admin/src/main/resources/templates/system/baseExpense/taskbxzgVerify.html +++ b/ruoyi-admin/src/main/resources/templates/system/baseExpense/taskbxzgVerify.html @@ -1,13 +1,13 @@ - +
-
- + + @@ -36,9 +36,9 @@
@@ -56,41 +56,91 @@
- +
- -
- + +
+
- -
-
-
- 选择报价信息 - - 添加物料 - + -
-
-
+
+ +
+
-
+ + + + + + + + + + + + + + + + +
+ \ No newline at end of file