| | |
| | | import com.zy.crm.manager.service.PlanService; |
| | | import com.zy.crm.manager.service.PlanTypeService; |
| | | import com.zy.crm.system.entity.User; |
| | | import com.zy.crm.system.service.DeptService; |
| | | import com.zy.crm.system.service.UserService; |
| | | import org.apache.poi.hssf.usermodel.HSSFWorkbook; |
| | | import org.apache.poi.ss.usermodel.DataFormatter; |
| | |
| | | private PlanService planService; |
| | | @Autowired |
| | | private PlanTypeService planTypeService; |
| | | @Autowired |
| | | private DeptService deptService; |
| | | |
| | | @GetMapping(value = "/plan/{id}/auth") |
| | | @ManagerAuth |
| | |
| | | } |
| | | resultObj.put("formHtml", planType.getHtml()); |
| | | // 步骤条相关 |
| | | resultObj.put("step", this.getStepOfSettle(plan.getSettle())); |
| | | resultObj.put("step", plan.getSettle() == 5 ? 0 : plan.getSettle() + 1); |
| | | |
| | | return R.ok().add(resultObj); |
| | | } |
| | |
| | | |
| | | @RequestMapping(value = "/plan/add/auth") |
| | | @ManagerAuth |
| | | @Transactional |
| | | public R add(@RequestParam Map<String, Object> param) { |
| | | // pre |
| | | Plan plan = JSON.parseObject(JSON.toJSONString(param), Plan.class); |
| | |
| | | |
| | | plan.setForm(JSON.toJSONString(param)); // 自定义表单内容 |
| | | plan.setSettle(1); // 1.开始 |
| | | plan.setSettleMsg(JSON.toJSONString(SettleDto.init(plan))); |
| | | User manager = userService.getDeptManager(hostId, getUser().getDeptId()); // 获取部门领导 |
| | | plan.setSettleMsg(JSON.toJSONString(SettleDto.init(plan, manager))); |
| | | |
| | | if (!planService.insert(plan)) { |
| | | throw new CoolException("保持失败,请重试"); |
| | | } |
| | | |
| | | // 自动添加跟进人 |
| | | PlanFoll planFoll = new PlanFoll(); |
| | | planFoll.setPlanId(plan.getId()); |
| | | planFoll.setUserId(manager.getId()); |
| | | if (!planFollService.insert(planFoll)) { |
| | | throw new CoolException("保持失败,请重试"); |
| | | } |
| | | |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | plan.setUpdateTime(new Date()); |
| | | |
| | | plan.setForm(JSON.toJSONString(param)); // 自定义表单内容 |
| | | plan.setSettleMsg(JSON.toJSONString(SettleDto.init(plan))); |
| | | |
| | | if (!planService.updateById(plan)) { |
| | | throw new CoolException("保持失败,请重试"); |
| | |
| | | for (Long id : ids){ |
| | | planService.deleteById(id); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | @PostMapping(value = "/plan/approval/auth") |
| | | @ManagerAuth |
| | | public R approval(@RequestParam Long planId){ |
| | | Plan plan = planService.selectById(planId); |
| | | assert plan != null; |
| | | |
| | | switch (plan.getSettle()) { |
| | | case 1: |
| | | // 本组组长审核 |
| | | User user = userService.selectById(plan.getUserId()); |
| | | User manager = userService.getDeptManager(getHostId(), user.getDeptId()); |
| | | if (manager.getId().equals(getUserId())) { |
| | | |
| | | // 查找规划组长 |
| | | plan.setSettleMsg(JSON.toJSONString(SettleDto.init(plan, manager))); |
| | | // 修改 settle 步骤数据 |
| | | |
| | | // 修改规划单状态 |
| | | plan.setSettle(2); // 规划组长待审 |
| | | plan.setUpdateBy(getUserId()); |
| | | plan.setUpdateTime(new Date()); |
| | | |
| | | if (!planService.updateById(plan)) { |
| | | throw new CoolException("审核失败,请联系管理员"); |
| | | } |
| | | |
| | | // 添加规划组长跟进人 |
| | | |
| | | } else { |
| | | return R.error("抱歉,您没有审核的权限"); |
| | | } |
| | | break; |
| | | case 2: |
| | | break; |
| | | case 3: |
| | | break; |
| | | case 4: |
| | | break; |
| | | default: |
| | | return R.error(); |
| | | } |
| | | |
| | | |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | throw new CoolException("删除失败,请联系管理员"); |
| | | } |
| | | return R.ok("删除成功"); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /*************************************** 步骤条相关 **********************************************/ |
| | | private Integer getStepOfSettle(int settle){ |
| | | switch (settle){ |
| | | case 1: |
| | | return 2; |
| | | case 2: |
| | | return 3; |
| | | case 3: |
| | | return 4; |
| | | case 4: |
| | | return 0; |
| | | default: |
| | | return 1; |
| | | } |
| | | } |
| | | |
| | | } |