| | |
| | | @Autowired |
| | | private UserService userService; |
| | | |
| | | @Autowired |
| | | private PriOnline2FollService priOnline2FollService; |
| | | |
| | | String PZH = " ———————————————————————————————————————————————————————————————————————————————— "; |
| | | |
| | | @RequestMapping(value = "/priOnline2/{id}/auth") |
| | |
| | | @RequestParam(defaultValue = "10") Integer limit, |
| | | @RequestParam(required = false) String orderByField, |
| | | @RequestParam(required = false) String orderByType, |
| | | @RequestParam(required = false) String allSwitch, |
| | | @RequestParam(required = false) String condition, |
| | | @RequestParam Map<String, Object> param) { |
| | | @RequestParam Map<String, Object> paramSou) { |
| | | EntityWrapper<PriOnline2> wrapper = new EntityWrapper<>(); |
| | | wrapper.setSqlSelect("id,title,create_time as createTime,filepath,settle,settle_size as settleSize,item_id as itemId,order_num as orderNum,template_name as templateName,user_id as userId,dept_id as deptId,status,update_time as updateTime,check_data as checkData,update_user_id as updateUserId,member_id as memberId"); |
| | | wrapper.setSqlSelect("id,title,create_time as createTime,assistant_plan_id as assistantPlanId,host_plan_id as hostPlanId,assistant_host_sign as assistantHostSign,filepath,settle,settle_size as settleSize,item_id as itemId,order_num as orderNum,template_name as templateName,user_id as userId,dept_id as deptId,status,update_time as updateTime,check_data as checkData,update_user_id as updateUserId,member_id as memberId"); |
| | | // wrapper.in("member_id", getUserRoleBelongsToUserId("allopen")); |
| | | excludeTrash(param); |
| | | excludeTrash(paramSou); |
| | | Map<String, Object> param = convertallSwitch(paramSou); |
| | | |
| | | if (!Cools.isEmpty(allSwitch)){ |
| | | List<PriOnline2> priOnline2List = priOnline2Service.listByAll(getUserId()); |
| | | Page<PriOnline2> page1 = new Page<PriOnline2>(curr, limit).setRecords(priOnline2List); |
| | | page1.setTotal(priOnline2Service.listByAllTotal(getUserId())); |
| | | return R.ok(page1); |
| | | } |
| | | |
| | | convert(param, wrapper); |
| | | allLike(PriOnline2.class, param.keySet(), wrapper, condition); |
| | | wrapper.or().eq("member_id", getUserId()); |
| | |
| | | return R.ok(priOnline2Service.selectPage(new Page<>(curr, limit), wrapper)); |
| | | } |
| | | |
| | | private Map<String, Object> convertallSwitch(Map<String, Object> map) { |
| | | for (Map.Entry<String, Object> entry : map.entrySet()) { |
| | | if (entry.getKey().equals("allSwitch")) { |
| | | map.remove("allSwitch"); |
| | | } |
| | | } |
| | | return map; |
| | | } |
| | | private <T> void convert(Map<String, Object> map, EntityWrapper<T> wrapper) { |
| | | boolean signUserId = false; |
| | | boolean signDeptId = false; |
| | |
| | | wrapper.or().eq("host_id", 1); |
| | | } |
| | | } |
| | | @RequestMapping(value = "/priOnline2/HJ/add/auth") |
| | | @ManagerAuth(memo = "接取集成核价任务") |
| | | public R addHJ(PriOnline2 priOnline2) { |
| | | PriOnline2 priOnline21 = priOnline2Service.selectById(priOnline2.getId()); |
| | | if (priOnline21.getSettle()!=1 || !priOnline21.getMemberId().equals(0L)){ |
| | | return R.error("此集成核价单状态已改变,请刷新页面重新选择!"); |
| | | } |
| | | Date now = new Date(); |
| | | priOnline21.setMemberId(getUserId()); |
| | | // @RequestMapping(value = "/priOnline2/HJ/add/auth") |
| | | // @ManagerAuth(memo = "接取集成核价任务") |
| | | // public R addHJ(PriOnline2 priOnline2) { |
| | | // PriOnline2 priOnline21 = priOnline2Service.selectById(priOnline2.getId()); |
| | | // if (priOnline21.getSettle()!=1 || !priOnline21.getMemberId().equals(0L)){ |
| | | // return R.error("此集成核价单状态已改变,请刷新页面重新选择!"); |
| | | // } |
| | | // Date now = new Date(); |
| | | // priOnline21.setMemberId(getUserId()); |
| | | // |
| | | // |
| | | // List<SettleDto> planDtos = JSON.parseArray(priOnline21.getSettleMsg(), SettleDto.class); |
| | | // List<SettleDto> planDtoList = new ArrayList<>(); |
| | | // for (SettleDto dto : planDtos) { |
| | | // if (dto.getStep().equals(2)) { |
| | | // dto.setUserId(getUserId()); |
| | | // dto.setUsername(getUser().getNickname()); |
| | | // if (Cools.isEmpty(dto.getMsg())) { |
| | | // dto.setMsg(getUser().getNickname() + "接取核价"); |
| | | // } else { |
| | | // dto.setMsg(dto.getMsg() + PZH + DateUtils.convert(now) + " " + getUser().getNickname() + "接取核价"); |
| | | // } |
| | | // dto.setTime(DateUtils.convert(new Date())); |
| | | // } |
| | | // planDtoList.add(dto); |
| | | // } |
| | | // priOnline21.setSettleMsg(JSON.toJSONString(planDtoList)); |
| | | // priOnline21.setUpdateUserId(getUserId()); |
| | | // priOnline21.setUpdateTime(now); |
| | | // priOnline2Service.updateById(priOnline21); |
| | | // return R.ok("接取成功"); |
| | | // } |
| | | |
| | | |
| | | List<SettleDto> planDtos = JSON.parseArray(priOnline21.getSettleMsg(), SettleDto.class); |
| | | List<SettleDto> planDtoList = new ArrayList<>(); |
| | | for (SettleDto dto : planDtos) { |
| | | if (dto.getStep().equals(2)) { |
| | | dto.setUserId(getUserId()); |
| | | dto.setUsername(getUser().getNickname()); |
| | | if (Cools.isEmpty(dto.getMsg())) { |
| | | dto.setMsg(getUser().getNickname() + "接取核价"); |
| | | } else { |
| | | dto.setMsg(dto.getMsg() + PZH + DateUtils.convert(now) + " " + getUser().getNickname() + "接取核价"); |
| | | } |
| | | dto.setTime(DateUtils.convert(new Date())); |
| | | } |
| | | planDtoList.add(dto); |
| | | } |
| | | priOnline21.setSettleMsg(JSON.toJSONString(planDtoList)); |
| | | priOnline21.setUpdateUserId(getUserId()); |
| | | priOnline21.setUpdateTime(now); |
| | | priOnline2Service.updateById(priOnline21); |
| | | return R.ok("接取成功"); |
| | | } |
| | | |
| | | @RequestMapping(value = "/priOnline2/HJ/search/auth") |
| | | @ManagerAuth |
| | | public R priOnline2Search(String condition) { |
| | | EntityWrapper<PriOnline2> wrapper = new EntityWrapper<>(); |
| | | wrapper.like("template_name", condition); |
| | | wrapper.eq("member_id",0L); |
| | | |
| | | List<ProcessPermissions> processPermissionsList = processPermissionsService.selectList(new EntityWrapper<ProcessPermissions>().eq("process_memo", 5));//2:核价流程 |
| | | int type =0; |
| | | for (ProcessPermissions processPermissions:processPermissionsList){ |
| | | if (getUserId().equals(processPermissions.getUserId())){ |
| | | type=1; |
| | | break; |
| | | } |
| | | } |
| | | if (type==0){ |
| | | return R.error("你不是核价员,无权接任务"); |
| | | } |
| | | List<Map<String, Object>> result = new ArrayList<>(); |
| | | |
| | | List<PriOnline2> priOnline2s = priOnline2Service.selectList(wrapper); |
| | | for (PriOnline2 priOnline2 : priOnline2s){ |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("id", priOnline2.getId()); |
| | | map.put("name", priOnline2.getTemplateName()+" - ID:"+priOnline2.getId()); |
| | | result.add(map); |
| | | } |
| | | return R.ok(result); |
| | | } |
| | | // @RequestMapping(value = "/priOnline2/HJ/search/auth") |
| | | // @ManagerAuth |
| | | // public R priOnline2Search(String condition) { |
| | | // EntityWrapper<PriOnline2> wrapper = new EntityWrapper<>(); |
| | | // wrapper.like("template_name", condition); |
| | | // wrapper.eq("member_id",0L); |
| | | // |
| | | // List<ProcessPermissions> processPermissionsList = processPermissionsService.selectList(new EntityWrapper<ProcessPermissions>().eq("process_memo", 5));//2:核价流程 |
| | | // int type =0; |
| | | // for (ProcessPermissions processPermissions:processPermissionsList){ |
| | | // if (getUserId().equals(processPermissions.getUserId())){ |
| | | // type=1; |
| | | // break; |
| | | // } |
| | | // } |
| | | // if (type==0){ |
| | | // return R.error("你不是核价员,无权接任务"); |
| | | // } |
| | | // List<Map<String, Object>> result = new ArrayList<>(); |
| | | // |
| | | // List<PriOnline2> priOnline2s = priOnline2Service.selectList(wrapper); |
| | | // for (PriOnline2 priOnline2 : priOnline2s){ |
| | | // Map<String, Object> map = new HashMap<>(); |
| | | // map.put("id", priOnline2.getId()); |
| | | // map.put("name", priOnline2.getTemplateName()+" - ID:"+priOnline2.getId()); |
| | | // result.add(map); |
| | | // } |
| | | // return R.ok(result); |
| | | // } |
| | | |
| | | |
| | | @RequestMapping(value = "/priOnline2/add/auth") |
| | |
| | | // Item item = itemService.selectById(priOnline.getItemId()); |
| | | Plan plan = planService.selectById(priOnline2.getItemId()); |
| | | User userUp = userService.selectById(plan.getUserId()); |
| | | priOnline2.setAssistantHostSign(plan.getAssistantHostSign()); |
| | | priOnline2.setAssistantPlanId(plan.getAssistantPlanId()); |
| | | priOnline2.setHostPlanId(plan.getId()); |
| | | if (plan.getAssistantHostSign()==1){ |
| | | priOnline2.setHostPlanId(plan.getHostPlanId()); |
| | | } |
| | | |
| | | |
| | | //业务员 |
| | | priOnline2.setUserId(userUp.getId()); |
| | |
| | | List<String> initNames = new ArrayList<>(); |
| | | initNames.add("接取核价任务"); |
| | | initNames.add("完成核价"); |
| | | if (planType.getType().equals(2)) { |
| | | initNames.add("完成核价"); |
| | | } |
| | | // initNames.add("经理审核"); |
| | | initNames.add("业务员确认"); |
| | | List<User> users = new ArrayList<>(); |
| | | users.add(getUser()); |
| | | users.add(getUser()); |
| | | if (planType.getType().equals(2)) { |
| | | users.add(new User()); |
| | | } |
| | | users.add(userUp); |
| | | priOnline2.setSettleMsg(JSON.toJSONString(SettleDto.InItFlowPath(users, initNames, users.size()))); |
| | | priOnline2.setSettleSize(users.size()); |
| | |
| | | planService.updateById(plan); |
| | | |
| | | priOnline2Service.insert(priOnline2); |
| | | |
| | | // 自动添加跟进人 |
| | | for (User user:users){ |
| | | List<PriOnline2Foll> priOnline2Folls = priOnline2FollService.selectList(new EntityWrapper<PriOnline2Foll>().eq("pri_online2_id", plan.getId()).eq("user_id", user.getId())); |
| | | if (Cools.isEmpty(priOnline2Folls) || priOnline2Folls.size()==0){ |
| | | PriOnline2Foll priOnline2Foll = new PriOnline2Foll(); |
| | | priOnline2Foll.setPriOnline2Id(plan.getId()); |
| | | priOnline2Foll.setUserId(user.getId()); |
| | | if (!priOnline2FollService.insert(priOnline2Foll)) { |
| | | throw new CoolException("保存失败,请重试"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | if (plan.getAssistantHostSign()==1){ |
| | | Plan plan1 = planService.selectById(plan.getHostPlanId()); |
| | | plan1.setStatus2(2); |
| | | planService.updateById(plan1); |
| | | } |
| | | |
| | | return R.ok(); |
| | | } |
| | | |
| | | @RequestMapping(value = "/priOnline2/addOther/auth") |
| | | @ManagerAuth(memo = "另存核价管理") |
| | | public R addOther(@RequestBody Map<String, Object> map) { |
| | | if (true){ |
| | | return R.error("禁止!"); |
| | | } |
| | | PriOnline2 online = priOnline2Service.selectById(Long.parseLong(map.get("id").toString())); |
| | | |
| | | PriOnline2 priOnline2 = new PriOnline2(); |
| | |
| | | Plan plan = planService.selectById(priOnline2.getItemId()); |
| | | plan.setStatus(1); |
| | | planService.updateById(plan); |
| | | if (plan.getAssistantHostSign()==1){ |
| | | Plan planHost = planService.selectById(priOnline2.getHostPlanId()); |
| | | planHost.setStatus2(1); |
| | | planService.updateById(planHost); |
| | | } |
| | | } |
| | | |
| | | priOnline2Service.deleteBatchIds(Arrays.asList(ids)); |
| | |
| | | if (!priOnline2Service.updateById(priOnline2)) { |
| | | throw new CoolException("确认失败,请联系管理员"); |
| | | } |
| | | |
| | | Plan plan = planService.selectById(priOnline2.getItemId()); |
| | | plan.setStatus(3); |
| | | planService.selectById(plan); |
| | | |
| | | if (user.getId().equals(priOnline2.getUserId())) { |
| | | try { |
| | | priQuoteAdd(priOnline2.getId(), plannerId); |
| | | } catch (Exception e) { |
| | | return R.error("自动生成报价单失败"); |
| | | if (priOnline2.getAssistantHostSign()==0){ |
| | | try { |
| | | priQuoteAdd(priOnline2.getId(), plannerId); |
| | | } catch (Exception e) { |
| | | return R.error("自动生成报价单失败"); |
| | | } |
| | | }else { |
| | | try { |
| | | Plan planHost = planService.selectById(priOnline2.getHostPlanId()); |
| | | planHost.setStatus2(3); |
| | | planService.selectById(planHost); |
| | | } catch (Exception e) { |
| | | return R.error("更新主表失败"); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | return R.ok("审批成功"); |