| | |
| | | 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.service.ItemService; |
| | | import com.zy.crm.manager.service.PlanService; |
| | | import com.zy.crm.manager.service.PriQuoteBudgetService; |
| | | import com.zy.crm.manager.service.PriQuoteService; |
| | | import com.zy.crm.manager.service.*; |
| | | import com.zy.crm.system.entity.User; |
| | | import com.zy.crm.system.service.UserService; |
| | | import org.apache.poi.xssf.usermodel.XSSFSheet; |
| | |
| | | |
| | | @Autowired |
| | | private PriQuoteBudgetService priQuoteBudgetService; |
| | | |
| | | @Autowired |
| | | private PlanTypeService planTypeService; |
| | | |
| | | @RequestMapping(value = "/priQuote/{id}/auth") |
| | | @ManagerAuth |
| | |
| | | priQuote.setForm(JSON.toJSONString(map)); // 自定义表单内容 |
| | | priQuote.setSettle(1); // 1.开始 |
| | | User manager = userService.getDeptManager(getHostId(), getUser().getDeptId()); // 获取部门领导 |
| | | priQuote.setSettleMsg(JSON.toJSONString(SettleDto.init(plan, manager))); |
| | | priQuote.setSettleMsg(JSON.toJSONString(SettleDto.initPriQuote(plan, manager))); |
| | | |
| | | planService.updateById(plan); |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | @PostMapping(value = "/priQuote/approval/auth") |
| | | @ManagerAuth |
| | | public R approvalPriQuote(@RequestParam Long planId, |
| | | @RequestParam(required = false) Long plannerId){return null;} |
| | | // PriQuote priQuote = priQuoteService.selectById(planId); |
| | | // assert priQuote != null; |
| | | // |
| | | // switch (priQuote.getSettle()) { |
| | | // case 1: |
| | | // // 本部门经理审核 |
| | | // User user = userService.selectById(priQuote.getUserId()); |
| | | // User manager = userService.getDeptManager(getHostId(), user.getDeptId()); |
| | | // if (manager.getId().equals(getUserId())) { |
| | | // |
| | | // |
| | | // // 查找总裁办 |
| | | // PlanType planType = planTypeService.selectById(priQuote.getPlanType()); |
| | | // User planLeader = planTypeService.findPlanLeader(planType); |
| | | // if (Cools.isEmpty(planLeader)) { |
| | | // throw new CoolException("未查找到总裁办,请联系管理员"); |
| | | // } |
| | | // |
| | | // // 修改 settle 步骤数据 |
| | | // List<SettleDto> list = JSON.parseArray(priQuote.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; |
| | | // case 3: |
| | | // dto.setUserId(planLeader.getId()); |
| | | // dto.setUsername(planLeader.getNickname()); |
| | | // break; |
| | | // default: |
| | | // break; |
| | | // } |
| | | // } |
| | | // priQuote.setSettleMsg(JSON.toJSONString(list)); |
| | | // |
| | | // // 修改规划单状态 |
| | | // priQuote.setSettle(2); // 规划组长待审 |
| | | // priQuote.setUpdateUserId(getUserId()); |
| | | // priQuote.setUpdateTime(new Date()); |
| | | // |
| | | // if (!priQuoteService.updateById(priQuote)) { |
| | | // throw new CoolException("审核失败,请联系管理员"); |
| | | // } |
| | | // |
| | | // // 添加规划组长跟进人 |
| | | // PlanFoll planFoll = new PlanFoll(); |
| | | // planFoll.setPlanId(priQuote.getId()); |
| | | // planFoll.setUserId(planLeader.getId()); |
| | | // if (!planFollService.insert(planFoll)) { |
| | | // throw new CoolException("审核失败,请联系管理员"); |
| | | // } |
| | | // |
| | | // } else { |
| | | // return R.error("抱歉,您没有审核的权限"); |
| | | // } |
| | | // break; |
| | | // case 2: |
| | | // // 查找规划组长 |
| | | // PlanType planType = planTypeService.selectById(priQuote.getPlanType()); |
| | | // User planLeader = planTypeService.findPlanLeader(planType); |
| | | // if (Cools.isEmpty(planLeader)) { |
| | | // throw new CoolException("未查找到规划组长,请联系管理员"); |
| | | // } |
| | | // if (Cools.isEmpty(planLeader)) { |
| | | // throw new CoolException("未查找到规划组长,请联系管理员"); |
| | | // } |
| | | // if (!getUserId().equals(planLeader.getId())) { |
| | | // return R.error("抱歉,您没有审核的权限"); |
| | | // } |
| | | // if (Cools.isEmpty(plannerId)) { |
| | | // return R.error("指定规划员不能为空"); |
| | | // } |
| | | // User planner = userService.selectById(plannerId); |
| | | // // 修改 settle 步骤数据 |
| | | // List<SettleDto> list = JSON.parseArray(priQuote.getSettleMsg(), SettleDto.class); |
| | | // for (SettleDto dto : list) { |
| | | // switch (dto.getStep()) { |
| | | // case 2: |
| | | // dto.setCurr(Boolean.FALSE); |
| | | // break; |
| | | // case 3: |
| | | // dto.setCurr(Boolean.TRUE); |
| | | // dto.setMsg("售前组长" + planLeader.getNickname() + "审批通过"); |
| | | // dto.setTime(DateUtils.convert(new Date())); |
| | | // break; |
| | | // case 4: |
| | | // dto.setUserId(planner.getId()); |
| | | // dto.setUsername(planner.getNickname()); |
| | | // break; |
| | | // default: |
| | | // break; |
| | | // } |
| | | // } |
| | | // priQuote.setSettleMsg(JSON.toJSONString(list)); |
| | | // // 修改规划单状态 |
| | | // priQuote.setSettle(3); // 规划员待审 |
| | | // priQuote.setPlanner(planner.getId()); |
| | | // priQuote.setUpdateUserId(getUserId()); |
| | | // priQuote.setUpdateTime(new Date()); |
| | | // |
| | | // if (!priQuoteService.updateById(priQuote)) { |
| | | // throw new CoolException("审核失败,请联系管理员"); |
| | | // } |
| | | // |
| | | // // 添加规划员跟进人 |
| | | // PlanFoll planFoll = new PlanFoll(); |
| | | // planFoll.setPlanId(priQuote.getId()); |
| | | // planFoll.setUserId(planner.getId()); |
| | | // if (!planFollService.insert(planFoll)) { |
| | | // throw new CoolException("审核失败,请联系管理员"); |
| | | // } |
| | | // break; |
| | | // case 3: |
| | | // User plannerUser = userService.selectById(priQuote.getPlanner()); |
| | | // if (Cools.isEmpty(plannerUser)) { |
| | | // return R.error("未找到规划员"); |
| | | // } |
| | | // if (!getUserId().equals(plannerUser.getId())) { |
| | | // return R.error("抱歉,您没有审核的权限"); |
| | | // } |
| | | // // 业务员 |
| | | // User salesman = userService.selectById(priQuote.getUserId()); |
| | | // // 修改 settle 步骤数据 |
| | | // List<SettleDto> list0 = JSON.parseArray(priQuote.getSettleMsg(), SettleDto.class); |
| | | // for (SettleDto dto : list0) { |
| | | // switch (dto.getStep()) { |
| | | // case 3: |
| | | // dto.setCurr(Boolean.FALSE); |
| | | // break; |
| | | // case 4: |
| | | // dto.setCurr(Boolean.TRUE); |
| | | // dto.setMsg("规划员" + plannerUser.getNickname() + "审批通过"); |
| | | // dto.setTime(DateUtils.convert(new Date())); |
| | | // break; |
| | | // case 5: |
| | | // dto.setUserId(salesman.getId()); |
| | | // dto.setUsername(salesman.getNickname()); |
| | | // break; |
| | | // default: |
| | | // break; |
| | | // } |
| | | // } |
| | | // priQuote.setSettleMsg(JSON.toJSONString(list0)); |
| | | // // 修改规划单状态 |
| | | // priQuote.setSettle(4); // 审批通过 |
| | | // priQuote.setUpdateUserId(getUserId()); |
| | | // priQuote.setUpdateTime(new Date()); |
| | | // |
| | | // if (!planService.updateById(priQuote)) { |
| | | // throw new CoolException("审核失败,请联系管理员"); |
| | | // } |
| | | // break; |
| | | // case 4: |
| | | // // 业务员 |
| | | // User salesman0 = userService.selectById(priQuote.getUserId()); |
| | | // if (!getUserId().equals(salesman0.getId())) { |
| | | // return R.error("抱歉,您没有审核的权限"); |
| | | // } |
| | | // // 修改 settle 步骤数据 |
| | | // List<SettleDto> list1 = JSON.parseArray(priQuote.getSettleMsg(), SettleDto.class); |
| | | // for (SettleDto dto : list1) { |
| | | // switch (dto.getStep()) { |
| | | // case 4: |
| | | // dto.setCurr(Boolean.TRUE); |
| | | // break; |
| | | // case 5: |
| | | // dto.setCurr(Boolean.TRUE); |
| | | // dto.setMsg("业务员" + salesman0.getNickname() + "审批通过"); |
| | | // dto.setTime(DateUtils.convert(new Date())); |
| | | // break; |
| | | // default: |
| | | // break; |
| | | // } |
| | | // } |
| | | // priQuote.setSettleMsg(JSON.toJSONString(list1)); |
| | | // // 修改规划单状态 |
| | | // priQuote.setSettle(5); // 审批通过 |
| | | // priQuote.setUpdateUserId(getUserId()); |
| | | // priQuote.setUpdateTime(new Date()); |
| | | // |
| | | // if (!planService.updateById(priQuote)) { |
| | | // throw new CoolException("审核失败,请联系管理员"); |
| | | // } |
| | | // break; |
| | | // default: |
| | | // return R.error(); |
| | | // } |
| | | // return R.ok("审批成功"); |
| | | // } |
| | | |
| | | } |