| | |
| | | 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.zy.crm.manager.controller.result.FollowerTableVo; |
| | | import com.zy.crm.manager.entity.Plan; |
| | | import com.zy.crm.manager.entity.PlanFoll; |
| | | import com.zy.crm.manager.entity.PlanType; |
| | | import com.zy.crm.manager.service.PlanFollService; |
| | | 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.UserService; |
| | | import org.apache.poi.hssf.usermodel.HSSFWorkbook; |
| | |
| | | |
| | | @Autowired |
| | | private PlanService planService; |
| | | @Autowired |
| | | private PlanTypeService planTypeService; |
| | | |
| | | @GetMapping(value = "/plan/{id}/auth") |
| | | @ManagerAuth |
| | | public R get(@PathVariable("id") String id) { |
| | | return R.ok(planService.selectById(String.valueOf(id))); |
| | | Plan plan = planService.selectById(String.valueOf(id)); |
| | | assert plan != null; |
| | | JSONObject resultObj = JSON.parseObject(JSON.toJSONString(plan)); |
| | | if (!Cools.isEmpty(plan.getForm())) { |
| | | JSONObject formObj = JSON.parseObject(plan.getForm()); |
| | | formObj.forEach(resultObj::putIfAbsent); |
| | | } |
| | | PlanType planType = planTypeService.selectById(plan.getPlanType()); |
| | | if (planType == null) { |
| | | return R.error("当前规划单类型已被禁用"); |
| | | } |
| | | resultObj.put("formHtml", planType.getHtml()); |
| | | return R.ok().add(resultObj); |
| | | } |
| | | |
| | | @RequestMapping(value = "/plan/page/auth") |
| | |
| | | ); |
| | | } |
| | | |
| | | private final List<String> fields = new ArrayList<>(); |
| | | |
| | | { |
| | | Arrays.asList(Cools.getAllFields(Plan.class)).forEach(item -> { |
| | | fields.add(item.getName()); |
| | | }); |
| | | } |
| | | |
| | | @RequestMapping(value = "/plan/add/auth") |
| | | @ManagerAuth |
| | | public R add(Plan plan) { |
| | | public R add(@RequestParam Map<String, Object> param) { |
| | | // pre |
| | | Plan plan = JSON.parseObject(JSON.toJSONString(param), Plan.class); |
| | | Iterator<Map.Entry<String, Object>> iterator = param.entrySet().iterator(); |
| | | while (iterator.hasNext()) { |
| | | Map.Entry<String, Object> next = iterator.next(); |
| | | if (this.fields.contains(next.getKey())) { |
| | | iterator.remove(); |
| | | } |
| | | } |
| | | // begin |
| | | Long hostId = getHostId(); |
| | | if (planService.selectByUuid(hostId, plan.getUuid()) != null) { |
| | | throw new CoolException("规划单已存在"); |
| | |
| | | plan.setUpdateTime(new Date()); |
| | | plan.setStatus(1); |
| | | |
| | | plan.setForm(JSON.toJSONString(param)); // 自定义表单内容 |
| | | plan.setSettle(1); // 1.开始 |
| | | |
| | | planService.insert(plan); |
| | | return R.ok(); |
| | | } |