| | |
| | | package com.zy.crm.manager.controller; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | |
| | | import com.zy.crm.system.service.UserService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.core.io.InputStreamResource; |
| | | import org.springframework.http.HttpHeaders; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.http.ResponseEntity; |
| | | import org.springframework.util.ClassUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.io.ByteArrayInputStream; |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.io.*; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | |
| | |
| | | @Autowired |
| | | private ProcessPermissionsService processPermissionsService; |
| | | |
| | | @RequestMapping(value = "/contract/{id}/auth") |
| | | @RequestMapping(value = "/contract/{id}/auth2") |
| | | @ManagerAuth |
| | | public R get(@PathVariable("id") String id) { |
| | | Contract contract = contractService.selectById(String.valueOf(id)); |
| | |
| | | } |
| | | } |
| | | if (!signUserId && !signDeptId){ |
| | | wrapper.eq("user_id", getUserId()); |
| | | if (getRole().getId()==1){ |
| | | wrapper.or().eq("host_id",getHostId()); |
| | | }else if (getRole().getId()==2){ |
| | | wrapper.eq("dept_id",getDeptId()); |
| | | }else { |
| | | wrapper.eq("user_id", getUserId()); |
| | | } |
| | | } |
| | | if (signHostId){ |
| | | wrapper.or().eq("host_id",1); |
| | | wrapper.or().eq("host_id",getHostId()); |
| | | } |
| | | } |
| | | |
| | |
| | | contract.setDeptId(getDeptId()); |
| | | contract.setCreateTime(now); |
| | | |
| | | contract.setSettle(0); |
| | | contract.setSettle(1); |
| | | |
| | | User manager = userService.getDeptManager(getHostId(), getUser().getDeptId()); // 获取部门领导 |
| | | User manager = new User(); |
| | | try{ |
| | | manager = userService.getDeptManager(getHostId(), getUser().getDeptId()); // 获取部门领导 |
| | | }catch (Exception e){ |
| | | manager = getUser(); |
| | | } |
| | | contract.setDirector(manager.getId()); |
| | | List<String> initNames = new ArrayList<>(); |
| | | initNames.add("创建产品费用明细模板"); |
| | | initNames.add("提交产品费用明细"); |
| | | initNames.add("创建合同模板"); |
| | | initNames.add("提交合同"); |
| | | initNames.add("部门经理审核"); |
| | | ProcessPermissions processPermissions = processPermissionsService.selectOne(new EntityWrapper<ProcessPermissions>().eq("process_memo", 7).eq("process", "3-1" ));//7:合同管理 |
| | | User president = userService.selectById(processPermissions.getUserId()); |
| | | initNames.add("总裁办"+president.getNickname()+"审核"); |
| | | initNames.add("总经办"+president.getNickname()+"审核"); |
| | | initNames.add("业务员确认"); |
| | | contract.setSettleMsg(JSON.toJSONString(SettleDto.initContract(manager,getUser(),president,initNames,4))); |
| | | |
| | |
| | | /////////////////////////生成Tab表格数据///////////////////////// |
| | | |
| | | String fileName = this.getClass().getClassLoader().getResource("contractTemplate/" + contractTemplate + ".docx").getPath();//获取文件路径 |
| | | return WordUtils.generate(fileName, map, tabParam); |
| | | |
| | | // String outPdfPath = fileName.split("\\.")[0]+".pdf"; |
| | | ResponseEntity<InputStreamResource> generate = WordUtils.generate(fileName, map, tabParam); |
| | | // WordUtils.documents4jWordToPdf(fileName,outPdfPath); |
| | | return generate; |
| | | } catch (Exception e) { |
| | | return null; |
| | | } |
| | |
| | | //文件后缀名 |
| | | String suffix = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")); |
| | | //上传文件名 |
| | | String filename = format.format(new Date()) + suffix; |
| | | String filename = format.format(new Date()) + "_" + file.getOriginalFilename(); |
| | | //最终文件路径 |
| | | String filepath = path + "/" + filename; |
| | | //OSS文件存储路径 |
| | |
| | | |
| | | @RequestMapping(value = "/contract/download/auth") |
| | | @ManagerAuth(memo = "下载合同") |
| | | public ResponseEntity<InputStreamResource> download(@RequestParam("id") Integer id) { |
| | | public R download(@RequestParam("id") Integer id) { |
| | | Contract contract = contractService.selectById(id); |
| | | if (contract == null) { |
| | | return null; |
| | | return R.error(); |
| | | } |
| | | if (Cools.isEmpty(contract.getFilepath())) { |
| | | return null; |
| | | return R.error(); |
| | | } |
| | | |
| | | try { |
| | | return ossService.downloadFile(contract.getFilepath());//从OSS中下载文件 |
| | | } catch (Exception e) { |
| | | return null; |
| | | } |
| | | String download = ossService.download(contract.getFilepath());//获取OSS临时下载URL |
| | | return R.ok().add(download); |
| | | } |
| | | |
| | | @RequestMapping(value = "/contract/export/auth") |
| | |
| | | return R.ok().add(vos); |
| | | } |
| | | |
| | | @PostMapping(value = "/contracr/approval/auth") |
| | | @PostMapping(value = "/contract/approval/auth") |
| | | @ManagerAuth |
| | | public R approvalBusinessTrip(@RequestParam Long contracrId, |
| | | public R approvalBusinessTrip(@RequestParam Long contractId, |
| | | @RequestParam(required = false) Long plannerId){ |
| | | Contract contract = contractService.selectById(contracrId); |
| | | Contract contract = contractService.selectById(contractId); |
| | | assert contract != null; |
| | | Date now = new Date(); |
| | | switch (contract.getSettle()) { |
| | | case 0: |
| | | User user2 = userService.selectById(contract.getUserId()); |
| | | User manager1 = userService.getDeptManager(getHostId(), user2.getDeptId()); |
| | | |
| | | if (Cools.isEmpty(getUser())) { |
| | | return R.error("抱歉,您没有提交的权限"); |
| | | } |
| | |
| | | dto.setMsg(getUser().getNickname() + "提交完成"); |
| | | dto.setTime(DateUtils.convert(now)); |
| | | break; |
| | | case 2: |
| | | contract.setDirector(dto.getUserId()); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | |
| | | break; |
| | | case 1: |
| | | // 本部门经理审核 |
| | | User user = userService.selectById(contract.getUserId()); |
| | | User manager = userService.getDeptManager(getHostId(), user.getDeptId()); |
| | | User manager = userService.selectById(contract.getDirector()); |
| | | |
| | | if (manager.getId().equals(getUserId())) { |
| | | |
| | | // 修改 settle 步骤数据 |
| | |
| | | dto.setCurr(Boolean.TRUE); |
| | | dto.setMsg("部门经理" + manager.getNickname() + "审批通过"); |
| | | dto.setTime(DateUtils.convert(now)); |
| | | break; |
| | | case 3: |
| | | contract.setDirector(dto.getUserId()); |
| | | break; |
| | | default: |
| | | break; |
| | |
| | | } |
| | | break; |
| | | case 2: |
| | | ProcessPermissions processPermissions = processPermissionsService.selectOne(new EntityWrapper<ProcessPermissions>().eq("process_memo", 7).eq("process", "3-1"));//3:报销流程 |
| | | User planLeader = userService.selectById(processPermissions.getUserId()); // 获取合同管理流程节点确认人 |
| | | User planLeader = userService.selectById(contract.getDirector()); |
| | | |
| | | if (planLeader.getId().equals(getUserId())) { |
| | | |
| | |
| | | dto.setMsg("总裁办" + planLeader.getNickname() + "审批通过"); |
| | | dto.setTime(DateUtils.convert(now)); |
| | | break; |
| | | case 4: |
| | | contract.setDirector(dto.getUserId()); |
| | | break; |
| | | default: |
| | | break; |
| | | } |