| | |
| | | package com.zy.crm.manager.controller; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | |
| | | import com.core.common.DateUtils; |
| | | import com.core.common.R; |
| | | import com.core.domain.KeyValueVo; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.crm.common.model.SettleDto; |
| | | import com.zy.crm.common.web.BaseController; |
| | | import com.zy.crm.manager.entity.*; |
| | | import com.zy.crm.manager.entity.param.ReimburseOnlineDomainParam; |
| | | import com.zy.crm.manager.service.*; |
| | | import com.zy.crm.manager.utils.RuleUtils; |
| | | import com.zy.crm.system.entity.User; |
| | | import com.zy.crm.system.service.UserService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.core.io.ClassPathResource; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | |
| | | @Autowired |
| | | private PlanService planService; |
| | | |
| | | @Autowired |
| | | private ReimburseOnlineDetlService reimburseOnlineDetlService; |
| | | |
| | | @Autowired |
| | | private RuleService ruleService; |
| | | |
| | | @Autowired |
| | | private UserService userService; |
| | | |
| | | @Autowired |
| | | private ProcessPermissionsService processPermissionsService; |
| | | |
| | | @RequestMapping(value = "/reimburseOnline/{id}/auth") |
| | | @ManagerAuth |
| | | public R get(@PathVariable("id") String id) { |
| | | return R.ok(reimburseOnlineService.selectById(String.valueOf(id))); |
| | | ReimburseOnline reimburseOnline = reimburseOnlineService.selectById(String.valueOf(id)); |
| | | assert reimburseOnline != null; |
| | | JSONObject resultObj = JSON.parseObject(JSON.toJSONString(reimburseOnline)); |
| | | if (!Cools.isEmpty(reimburseOnline.getForm())) { |
| | | JSONObject formObj = JSON.parseObject(reimburseOnline.getForm()); |
| | | formObj.forEach(resultObj::putIfAbsent); |
| | | } |
| | | |
| | | // 步骤条相关 |
| | | resultObj.put("step", reimburseOnline.getSettle() == 6 ? 0 : reimburseOnline.getSettle() + 1); |
| | | |
| | | return R.ok().add(resultObj); |
| | | } |
| | | |
| | | @RequestMapping(value = "/reimburseOnline/viewCheck/{id}/auth") |
| | |
| | | Date now = new Date(); |
| | | Rule rule = ruleService.selectById(1); |
| | | ReimburseOnline reimburseOnline = new ReimburseOnline(planId,RuleUtils.rule(rule),now,getUser()); |
| | | reimburseOnline.setMemberId(getUserId()); |
| | | reimburseOnline.setCheckData(param.getCheckData()); |
| | | reimburseOnline.setTemplateName(param.getTemplateName()); |
| | | |
| | | reimburseOnline.setSettle(1); // 1.开始 |
| | | User manager = userService.getDeptManager(getHostId(), getUser().getDeptId()); // 获取部门领导 |
| | | |
| | | ProcessPermissions processPermissions3 = processPermissionsService.selectOne(new EntityWrapper<ProcessPermissions>().eq("process_memo", 3).eq("process", param.getCheckData().equals("否")? "3-1" : "3-2"));//3:报销流程 |
| | | User president3 = userService.selectById(processPermissions3.getUserId()); // 获取报价流程节点3确认人 |
| | | |
| | | ProcessPermissions processPermissions4 = processPermissionsService.selectOne(new EntityWrapper<ProcessPermissions>().eq("process_memo", 3).eq("process", "4-1"));//3:报销流程 |
| | | User president4 = userService.selectById(processPermissions4.getUserId()); // 获取报价流程节点4确认人 |
| | | |
| | | ProcessPermissions processPermissions5 = processPermissionsService.selectOne(new EntityWrapper<ProcessPermissions>().eq("process_memo", 3).eq("process", "5-1"));//3:报销流程 |
| | | User president5 = userService.selectById(processPermissions5.getUserId()); // 获取报价流程节点5确认人 |
| | | |
| | | ProcessPermissions processPermissions6 = processPermissionsService.selectOne(new EntityWrapper<ProcessPermissions>().eq("process_memo", 3).eq("process", "6-1"));//3:报销流程 |
| | | User president6 = userService.selectById(processPermissions6.getUserId()); // 获取报价流程节点6确认人 |
| | | |
| | | reimburseOnline.setSettleMsg(JSON.toJSONString(SettleDto.initPriQuote(reimburseOnline, manager,president3,president4,president5,president6,getUser()))); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("title","非项目型报销"); |
| | | map.put("reimburseId",param.getReimburseId()); |
| | | map.put("docType",param.getDocType()); |
| | | map.put("orderNo",param.getOrderNo()); |
| | | map.put("templateName",param.getTemplateName()); |
| | | map.put("checkData",param.getCheckData()); |
| | | map.put("reimburseOnlineDetls",param.getReimburseOnlineDetls()); |
| | | reimburseOnline.setForm(JSON.toJSONString(map)); |
| | | reimburseOnline.setMemberId(president3.getId()); |
| | | |
| | | if (!reimburseOnlineService.insert(reimburseOnline)){ |
| | | return R.error("添加报销主档失败"); |
| | | } |
| | |
| | | return R.ok().add(vos); |
| | | } |
| | | |
| | | @PostMapping(value = "/reimburseOnline/approval/auth") |
| | | @ManagerAuth |
| | | public R approvalReimburseOnline(@RequestParam Long planId, |
| | | @RequestParam(required = false) Long plannerId){ |
| | | ReimburseOnline reimburseOnline = reimburseOnlineService.selectById(planId); |
| | | assert reimburseOnline != null; |
| | | Integer settle = reimburseOnline.getSettle(); |
| | | String process=""; |
| | | switch (reimburseOnline.getSettle()) { |
| | | case 1: |
| | | // 本部门经理审核 |
| | | User user = userService.selectById(reimburseOnline.getUserId()); |
| | | User manager = userService.getDeptManager(getHostId(), user.getDeptId()); |
| | | if (manager.getId().equals(getUserId())) { |
| | | |
| | | // 修改 settle 步骤数据 |
| | | List<SettleDto> list = JSON.parseArray(reimburseOnline.getSettleMsg(), SettleDto.class); |
| | | for (SettleDto dto : list) { |
| | | switch (dto.getStep()) { |
| | | case 1: |
| | | dto.setCurr(Boolean.FALSE); |
| | | break; |
| | | case 2: |
| | | dto.setCurr(Boolean.TRUE); |
| | | dto.setMsg("部门经理" + manager.getNickname() + "审批通过"); |
| | | dto.setTime(DateUtils.convert(new Date())); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | } |
| | | reimburseOnline.setSettleMsg(JSON.toJSONString(list)); |
| | | |
| | | // 修改规划单状态 |
| | | reimburseOnline.setSettle(2); // 总裁办待审 |
| | | reimburseOnline.setUpdateUserId(getUserId()); |
| | | reimburseOnline.setUpdateTime(new Date()); |
| | | |
| | | if (!reimburseOnlineService.updateById(reimburseOnline)) { |
| | | throw new CoolException("审核失败,请联系管理员"); |
| | | } |
| | | |
| | | } else { |
| | | return R.error("抱歉,您没有审核的权限"); |
| | | } |
| | | break; |
| | | case 2: |
| | | if (reimburseOnline.getCheckData().equals("否")){ |
| | | process="3-1"; |
| | | }else { |
| | | process="3-2"; |
| | | } |
| | | case 3: |
| | | if (Cools.isEmpty(process) || process.equals("")){ |
| | | process="4-1"; |
| | | } |
| | | case 4: |
| | | if (Cools.isEmpty(process) || process.equals("")){ |
| | | process="5-1"; |
| | | } |
| | | case 5: |
| | | if (Cools.isEmpty(process) || process.equals("")){ |
| | | process="6-1"; |
| | | } |
| | | ProcessPermissions processPermissions = processPermissionsService.selectOne(new EntityWrapper<ProcessPermissions>().eq("process_memo", 3).eq("process", process));//3:报销流程 |
| | | User planLeader = userService.selectById(processPermissions.getUserId()); // 获取报价流程节点确认人 |
| | | |
| | | if (Cools.isEmpty(planLeader)) { |
| | | throw new CoolException("未查找到报价流程节点"+process+"确认人,请联系在审批权限添加确认人!"); |
| | | } |
| | | if (!getUserId().equals(planLeader.getId())) { |
| | | return R.error("抱歉,您没有审核的权限"); |
| | | } |
| | | // 修改 settle 步骤数据 |
| | | List<SettleDto> list = JSON.parseArray(reimburseOnline.getSettleMsg(), SettleDto.class); |
| | | for (SettleDto dto : list) { |
| | | if (dto.getStep().equals(settle)){ |
| | | dto.setCurr(Boolean.FALSE); |
| | | break; |
| | | }else if (dto.getStep().equals(settle+1)){ |
| | | dto.setCurr(Boolean.TRUE); |
| | | dto.setMsg("报价流程节点"+process+"确认人:"+planLeader.getNickname() + "审批通过"); |
| | | dto.setTime(DateUtils.convert(new Date())); |
| | | break; |
| | | }else { |
| | | break; |
| | | } |
| | | } |
| | | reimburseOnline.setSettleMsg(JSON.toJSONString(list)); |
| | | // 修改规划单状态 |
| | | reimburseOnline.setSettle(settle+1); |
| | | reimburseOnline.setUpdateUserId(getUserId()); |
| | | reimburseOnline.setUpdateTime(new Date()); |
| | | reimburseOnline.setMemberId(planLeader.getId()); |
| | | |
| | | if (!reimburseOnlineService.updateById(reimburseOnline)) { |
| | | throw new CoolException("审核失败,请联系管理员"); |
| | | } |
| | | break; |
| | | default: |
| | | return R.error(); |
| | | } |
| | | return R.ok("审批成功"); |
| | | } |
| | | |
| | | } |