中扬CRM客户关系管理系统
#
luxiaotao1123
2022-11-25 582a42c9fc685a26254ffb50b4d4aeb1436125d2
src/main/java/com/zy/crm/manager/controller/PlanController.java
@@ -21,6 +21,7 @@
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;
@@ -44,6 +45,8 @@
    private PlanService planService;
    @Autowired
    private PlanTypeService planTypeService;
    @Autowired
    private DeptService deptService;
    @GetMapping(value = "/plan/{id}/auth")
    @ManagerAuth
@@ -61,7 +64,7 @@
        }
        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);
    }
@@ -91,6 +94,7 @@
    @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);
@@ -119,11 +123,21 @@
        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();
    }
@@ -140,7 +154,6 @@
        plan.setUpdateTime(new Date());
        plan.setForm(JSON.toJSONString(param));     // 自定义表单内容
        plan.setSettleMsg(JSON.toJSONString(SettleDto.init(plan)));
        if (!planService.updateById(plan)) {
            throw new CoolException("保持失败,请重试");
@@ -154,6 +167,52 @@
         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();
    }
@@ -289,29 +348,6 @@
            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;
        }
    }
}