| | |
| | | import com.baomidou.mybatisplus.plugins.Page; |
| | | import com.core.common.DateUtils; |
| | | import com.zy.crm.common.utils.FileSaveExampleUtil; |
| | | import com.zy.crm.manager.entity.PlanUrl; |
| | | import com.zy.crm.manager.service.PlanUrlService; |
| | | import com.zy.crm.manager.entity.*; |
| | | import com.zy.crm.manager.service.*; |
| | | import com.core.annotations.ManagerAuth; |
| | | import com.core.common.BaseRes; |
| | | import com.core.common.Cools; |
| | |
| | | |
| | | @Autowired |
| | | private PlanUrlService planUrlService; |
| | | |
| | | @Autowired |
| | | private PlanService planService; |
| | | |
| | | @Autowired |
| | | private PriOnline2Service priOnline2Service; |
| | | |
| | | @Autowired |
| | | private PriQuoteService priQuoteService; |
| | | |
| | | @Autowired |
| | | private PlanTypeService planTypeService; |
| | | |
| | | @Autowired |
| | | private ProcessPermissionsService processPermissionsService; |
| | | |
| | | Integer PBN = 6; |
| | | |
| | | @RequestMapping(value = "/plan/url/view/file/auth") |
| | | @ManagerAuth |
| | | public R viewFile(@RequestParam("planId") String planId){ |
| | | List<FileSaveExampleUtil.FileDTO> fileDTOS = new ArrayList<>(); |
| | | if (Cools.isEmpty(planId)){ |
| | | return R.ok(fileDTOS); |
| | | } |
| | | Long id = Long.parseLong(planId); |
| | | Plan plan = planService.selectById(id); |
| | | PlanType planType = planTypeService.selectById(plan.getPlanType()); |
| | | if (plan.getAssistantHostSign()==1){ |
| | | planType.setType(1); |
| | | } |
| | | // String savePath = "D:/crm/plan/file/"+id+"/"; // 指定保存文件的路径 |
| | | try{ |
| | | List<PlanUrl> planUrls = planUrlService.selectPlanUrlByPlanId(id,0,planType.getType(),0); |
| | | for (PlanUrl planUrl : planUrls){ |
| | | FileSaveExampleUtil.FileDTO dto = new FileSaveExampleUtil.FileDTO(planUrl); |
| | | fileDTOS.add(dto); |
| | | } |
| | | // List<FileSaveExampleUtil.FileDTO> fileDTOS = FileSaveExampleUtil.viewFileList(savePath); |
| | | return R.ok(fileDTOS); |
| | | }catch (Exception e){ |
| | | return R.error(); |
| | | } |
| | | } |
| | | |
| | | @RequestMapping(value = "/plan/url/insert/file/auth") |
| | | @ManagerAuth |
| | | public R insertFile(@RequestParam("planId") String planId, @RequestParam("filename") String filename, |
| | | @RequestParam("filesize") Long filesize) { |
| | | try { |
| | | User user = getUser(); |
| | | String[] split = planId.split("-"); |
| | | Long id = Long.parseLong(split[1]); |
| | | Long idPlan = Long.parseLong(split[2]); |
| | | Plan plan = planService.selectById(idPlan); |
| | | PlanType planType = planTypeService.selectById(plan.getPlanType()); |
| | | int status = 0; |
| | | if (plan.getUserId().equals(getUserId())){ |
| | | status=1; |
| | | }else { |
| | | status=2; |
| | | } |
| | | if (plan.getAssistantHostSign()==1){ |
| | | planType.setType(1); |
| | | } |
| | | String url = "http://zhongyang-ftpserver.oss-cn-hangzhou.aliyuncs.com/" + filename; |
| | | PlanUrl planUrl = new PlanUrl(id, url, filename, filesize,user.getNickname(),user.getId(),1,planType.getType(),status); |
| | | planUrlService.insert(planUrl); |
| | | return R.ok(); |
| | | } catch (Exception e) { |
| | | System.out.println(e); |
| | | return R.error(); |
| | | } |
| | | } |
| | | |
| | | @RequestMapping(value = "/pri/online/url/view/file/auth") |
| | | @ManagerAuth |
| | | public R viewFilePriOnline(@RequestParam("planId") String planId){ |
| | | List<FileSaveExampleUtil.FileDTO> fileDTOS = new ArrayList<>(); |
| | | if (Cools.isEmpty(planId)){ |
| | | return R.ok(fileDTOS); |
| | | } |
| | | Long id = Long.parseLong(planId); |
| | | int planType =0; |
| | | Plan plan = planService.selectById(id); |
| | | if (plan.getAssistantHostSign()==1){ |
| | | planType=1; |
| | | }else { |
| | | if (!plan.getUserId().equals(getUserId())){ |
| | | List<ProcessPermissions> processPermissionsList = processPermissionsService.selectList(new EntityWrapper<ProcessPermissions>().eq("process_memo", 4).or().eq("process_memo", 5));//2:核价流程 |
| | | for (ProcessPermissions processPermissions:processPermissionsList){ |
| | | if (getUserId().equals(processPermissions.getUserId())){ |
| | | planType=PBN-processPermissions.getProcessMemo(); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | // String savePath = "D:/crm/plan/file/"+id+"/"; // 指定保存文件的路径 |
| | | try{ |
| | | List<PlanUrl> planUrls = planUrlService.selectPlanUrlByPlanId(id,0,planType,0); |
| | | for (PlanUrl planUrl : planUrls){ |
| | | if (!plan.getUserId().equals(getUserId())){ |
| | | if (planUrl.getType()==3){ |
| | | continue; |
| | | } |
| | | } |
| | | FileSaveExampleUtil.FileDTO dto = new FileSaveExampleUtil.FileDTO(planUrl); |
| | | fileDTOS.add(dto); |
| | | } |
| | | // List<FileSaveExampleUtil.FileDTO> fileDTOS = FileSaveExampleUtil.viewFileList(savePath); |
| | | return R.ok(fileDTOS); |
| | | }catch (Exception e){ |
| | | return R.error(); |
| | | } |
| | | } |
| | | |
| | | @RequestMapping(value = "/pri/online/url/insert/file/auth") |
| | | @ManagerAuth |
| | | public R insertFilePriOnline(@RequestParam("planId") String planId, @RequestParam("filename") String filename, |
| | | @RequestParam("filesize") Long filesize) { |
| | | try { |
| | | User user = getUser(); |
| | | String[] split = planId.split("-"); |
| | | Long id = Long.parseLong(split[1]); |
| | | Long idPriOnline = Long.parseLong(split[2]); |
| | | PriOnline2 priOnline2 = priOnline2Service.selectById(idPriOnline); |
| | | Plan plan = planService.selectById(priOnline2.getItemId()); |
| | | PlanType planType = planTypeService.selectById(plan.getPlanType()); |
| | | int status = 0; |
| | | if (plan.getUserId().equals(getUserId())){ |
| | | status=1; |
| | | }else { |
| | | status=2; |
| | | } |
| | | if (plan.getAssistantHostSign()==1){ |
| | | planType.setType(1); |
| | | } |
| | | String url = "http://zhongyang-ftpserver.oss-cn-hangzhou.aliyuncs.com/" + filename; |
| | | PlanUrl planUrl = new PlanUrl(id, url, filename, filesize,user.getNickname(),user.getId(),2,planType.getType(),status); |
| | | planUrlService.insert(planUrl); |
| | | return R.ok(); |
| | | } catch (Exception e) { |
| | | System.out.println(e); |
| | | return R.error(); |
| | | } |
| | | } |
| | | |
| | | @RequestMapping(value = "/pri/quote/url/view/file/auth") |
| | | @ManagerAuth |
| | | public R viewFilePriQuote(@RequestParam("planId") String planId){ |
| | | List<FileSaveExampleUtil.FileDTO> fileDTOS = new ArrayList<>(); |
| | | if (Cools.isEmpty(planId)){ |
| | | return R.ok(fileDTOS); |
| | | } |
| | | Long id = Long.parseLong(planId); |
| | | // String savePath = "D:/crm/plan/file/"+id+"/"; // 指定保存文件的路径 |
| | | try{ |
| | | List<PlanUrl> planUrls = planUrlService.selectPlanUrlByPlanId(id,0,0,0); |
| | | for (PlanUrl planUrl : planUrls){ |
| | | FileSaveExampleUtil.FileDTO dto = new FileSaveExampleUtil.FileDTO(planUrl); |
| | | fileDTOS.add(dto); |
| | | } |
| | | // List<FileSaveExampleUtil.FileDTO> fileDTOS = FileSaveExampleUtil.viewFileList(savePath); |
| | | return R.ok(fileDTOS); |
| | | }catch (Exception e){ |
| | | return R.error(); |
| | | } |
| | | } |
| | | |
| | | @RequestMapping(value = "/pri/quote/url/insert/file/auth") |
| | | @ManagerAuth |
| | | public R insertFilePriQuote(@RequestParam("planId") String planId, @RequestParam("filename") String filename, |
| | | @RequestParam("filesize") Long filesize) { |
| | | try { |
| | | User user = getUser(); |
| | | String[] split = planId.split("-"); |
| | | Long id = Long.parseLong(split[1]); |
| | | Long idPriQuote = Long.parseLong(split[2]); |
| | | PriQuote priQuote = priQuoteService.selectById(idPriQuote); |
| | | Plan plan = planService.selectById(priQuote.getItemId()); |
| | | PlanType planType = planTypeService.selectById(plan.getPlanType()); |
| | | int status = 0; |
| | | if (plan.getUserId().equals(getUserId())){ |
| | | status=1; |
| | | }else { |
| | | status=2; |
| | | } |
| | | if (plan.getAssistantHostSign()==1){ |
| | | planType.setType(1); |
| | | } |
| | | String url = "http://zhongyang-ftpserver.oss-cn-hangzhou.aliyuncs.com/" + filename; |
| | | PlanUrl planUrl = new PlanUrl(id, url, filename, filesize,user.getNickname(),user.getId(),3,planType.getType(),status); |
| | | planUrlService.insert(planUrl); |
| | | return R.ok(); |
| | | } catch (Exception e) { |
| | | System.out.println(e); |
| | | return R.error(); |
| | | } |
| | | } |
| | | |
| | | |
| | | // @RequestMapping(value = "/planUrl/{id}/auth") |
| | | // @ManagerAuth |
| | |
| | | // planUrlService.selectPage(new Page<>(1, 30), wrapper).getRecords().forEach(item -> vos.add(new KeyValueVo(String.valueOf(item.getId()), item.getId()))); |
| | | // return R.ok().add(vos); |
| | | // } |
| | | |
| | | @RequestMapping(value = "/plan/url/view/file/auth") |
| | | // @ManagerAuth |
| | | public R viewFile(@RequestParam("planId") String planId){ |
| | | List<FileSaveExampleUtil.FileDTO> fileDTOS = new ArrayList<>(); |
| | | if (Cools.isEmpty(planId)){ |
| | | return R.ok(fileDTOS); |
| | | } |
| | | Long id = Long.parseLong(planId); |
| | | // String savePath = "D:/crm/plan/file/"+id+"/"; // 指定保存文件的路径 |
| | | try{ |
| | | List<PlanUrl> planUrls = planUrlService.selectPlanUrlByPlanId(id); |
| | | for (PlanUrl planUrl : planUrls){ |
| | | FileSaveExampleUtil.FileDTO dto = new FileSaveExampleUtil.FileDTO(planUrl); |
| | | fileDTOS.add(dto); |
| | | } |
| | | // List<FileSaveExampleUtil.FileDTO> fileDTOS = FileSaveExampleUtil.viewFileList(savePath); |
| | | return R.ok(fileDTOS); |
| | | }catch (Exception e){ |
| | | return R.error(); |
| | | } |
| | | } |
| | | |
| | | @RequestMapping(value = "/plan/url/insert/file/auth") |
| | | // @ManagerAuth |
| | | public R insertFile(@RequestParam("planId") String planId, @RequestParam("filename") String filename, |
| | | @RequestParam("filesize") Long filesize,@RequestParam("token") String token) { |
| | | try { |
| | | String nickname = null; |
| | | Long userId = null; |
| | | if (!Cools.isEmpty(token)) { |
| | | User user = getUser(token); |
| | | nickname = user.getNickname(); |
| | | userId = user.getId(); |
| | | } |
| | | String[] split = planId.split("-"); |
| | | Long id = Long.parseLong(split[1]); |
| | | String url = "http://zhongyang-ftpserver.oss-cn-hangzhou.aliyuncs.com/" + filename; |
| | | PlanUrl planUrl = new PlanUrl(id, url, filename, filesize,nickname,userId,0,0,0); |
| | | planUrlService.insert(planUrl); |
| | | return R.ok(); |
| | | } catch (Exception e) { |
| | | System.out.println(e); |
| | | return R.error(); |
| | | } |
| | | } |
| | | |
| | | } |