|  |  |  | 
|---|
|  |  |  | @RequestParam(required = false)String condition, | 
|---|
|  |  |  | @RequestParam Map<String, Object> param){ | 
|---|
|  |  |  | EntityWrapper<PriQuote> wrapper = new EntityWrapper<>(); | 
|---|
|  |  |  | wrapper.setSqlSelect("id,title,create_time as createTime,filepath,item_id as itemId,order_num as orderNum,template_name as templateName,sheet_data as sheetData,user_id as userId,dept_id as deptId,settle,settle_msg as settleMsg,form,update_user_id as updateUserId,update_time as updateTime,in_order_num as inOrderNum,member_id as memberId"); | 
|---|
|  |  |  | wrapper.in("member_id", getUserRoleBelongsToUserId()); | 
|---|
|  |  |  | wrapper.setSqlSelect("id,title,create_time as createTime,filepath,item_id as itemId,order_num as orderNum,template_name as templateName,sheet_data as sheetData,user_id as userId,dept_id as deptId,settle,settle_msg as settleMsg,form,update_user_id as updateUserId,update_time as updateTime,in_order_num as inOrderNum,member_id as memberId,template"); | 
|---|
|  |  |  | //        wrapper.in("member_id", getUserRoleBelongsToUserId()); | 
|---|
|  |  |  | excludeTrash(param); | 
|---|
|  |  |  | convert(param, wrapper); | 
|---|
|  |  |  | allLike(PriQuote.class, param.keySet(), wrapper, condition); | 
|---|
|  |  |  | wrapper.or().eq("member_id",getUserId()); | 
|---|
|  |  |  | if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));} | 
|---|
|  |  |  | return R.ok(priQuoteService.selectPage(new Page<>(curr, limit), wrapper)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping(value = "/priQuote/add/auth") | 
|---|
|  |  |  | @ManagerAuth | 
|---|
|  |  |  | @ManagerAuth(memo = "添加报价单") | 
|---|
|  |  |  | public R add(@RequestBody Map<String,Object> map) { | 
|---|
|  |  |  | PriQuoteBudget priQuoteBudget = priQuoteBudgetService.selectById(Long.parseLong(map.get("priQuoteBudgetId").toString())); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | priQuote.setTitle(map.get("title").toString()); | 
|---|
|  |  |  | priQuote.setTemplateName(priQuoteBudget.getTemplateName()); | 
|---|
|  |  |  | priQuote.setSheetData(map.get("sheetData").toString()); | 
|---|
|  |  |  | priQuote.setOriQuoteBudgetId(Long.parseLong(map.get("priQuoteBudgetId").toString())); | 
|---|
|  |  |  | priQuote.setItemId(priQuoteBudget.getItemId()); | 
|---|
|  |  |  | priQuote.setOrderNum(priQuoteBudget.getInOrderNum()); | 
|---|
|  |  |  | SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss"); | 
|---|
|  |  |  | 
|---|
|  |  |  | priQuote.setDeptId(getDeptId()); | 
|---|
|  |  |  | //更新时间 | 
|---|
|  |  |  | priQuote.setUpdateTime(new Date()); | 
|---|
|  |  |  | //模板 | 
|---|
|  |  |  | priQuote.setTemplate(map.get("template").toString()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //业务员 | 
|---|
|  |  |  | Plan plan = planService.selectById(priQuote.getItemId()); | 
|---|
|  |  |  | 
|---|
|  |  |  | priQuote.setForm(JSON.toJSONString(map));     // 自定义表单内容 | 
|---|
|  |  |  | priQuote.setSettle(1);  // 1.开始 | 
|---|
|  |  |  | User manager = userService.getDeptManager(getHostId(), getUser().getDeptId());        // 获取部门领导 | 
|---|
|  |  |  | ProcessPermissions processPermissions = processPermissionsService.selectOne(new EntityWrapper<ProcessPermissions>().eq("process_memo", 2).eq("process", 3));//2:报价流程 | 
|---|
|  |  |  | User president = userService.selectById(processPermissions.getUserId());       // 获取报价流程节点3确认人 | 
|---|
|  |  |  | ProcessPermissions processPermissions = processPermissionsService.selectOne(new EntityWrapper<ProcessPermissions>().eq("process_memo", 2).eq("process", "3-1"));//2:报价流程 | 
|---|
|  |  |  | User president = userService.selectById(processPermissions.getUserId());       // 获取报价流程节点3-1确认人 | 
|---|
|  |  |  | priQuote.setSettleMsg(JSON.toJSONString(SettleDto.initPriQuote(plan, manager,president,getUser()))); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | planService.updateById(plan); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping(value = "/priQuote/addOther/auth") | 
|---|
|  |  |  | @ManagerAuth | 
|---|
|  |  |  | @ManagerAuth(memo = "另存报价单") | 
|---|
|  |  |  | public R addOther(@RequestBody Map<String,Object> map) { | 
|---|
|  |  |  | PriQuote quote = priQuoteService.selectById(Long.parseLong(map.get("id").toString())); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping(value = "/priQuote/update/auth") | 
|---|
|  |  |  | @ManagerAuth | 
|---|
|  |  |  | @ManagerAuth(memo = "更新报价单") | 
|---|
|  |  |  | public R update(@RequestBody Map<String,Object> map){ | 
|---|
|  |  |  | PriQuote priQuote = priQuoteService.selectById(Long.parseLong(map.get("id").toString())); | 
|---|
|  |  |  | priQuote.setTitle(map.get("title").toString()); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping(value = "/priQuote/updateForm/auth") | 
|---|
|  |  |  | @ManagerAuth | 
|---|
|  |  |  | @ManagerAuth(memo = "更新报价单") | 
|---|
|  |  |  | public R updateForm(Long id,String templateName,String title){ | 
|---|
|  |  |  | PriQuote priQuote = priQuoteService.selectById(id); | 
|---|
|  |  |  | priQuote.setTemplateName(templateName); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping(value = "/priQuote/delete/auth") | 
|---|
|  |  |  | @ManagerAuth | 
|---|
|  |  |  | @ManagerAuth(memo = "删除报价单") | 
|---|
|  |  |  | public R delete(Long[] ids){ | 
|---|
|  |  |  | if (Cools.isEmpty(ids)){ | 
|---|
|  |  |  | return R.error(); | 
|---|
|  |  |  | 
|---|
|  |  |  | public R query(String condition) { | 
|---|
|  |  |  | EntityWrapper<PriQuote> wrapper = new EntityWrapper<>(); | 
|---|
|  |  |  | wrapper.like("id", condition); | 
|---|
|  |  |  | wrapper.in("member_id", getUserRoleBelongsToUserId()); | 
|---|
|  |  |  | wrapper.in("user_id", getUserRoleBelongsToUserId()); | 
|---|
|  |  |  | Page<PriQuote> page = priQuoteService.selectPage(new Page<>(0, 10), wrapper); | 
|---|
|  |  |  | List<Map<String, Object>> result = new ArrayList<>(); | 
|---|
|  |  |  | for (PriQuote priQuote : page.getRecords()){ | 
|---|
|  |  |  | 
|---|
|  |  |  | String path =  ClassUtils.getDefaultClassLoader().getResource("excel").getPath(); | 
|---|
|  |  |  | String filename = format.format(new Date()) + ".xlsx"; | 
|---|
|  |  |  | String filepath = path + "/" + filename; | 
|---|
|  |  |  | exportLuckySheetXlsx(path,"/" + filename,map.get("exceldata").toString()); | 
|---|
|  |  |  | exportLuckySheetXlsx(path, "/" + filename, map.get("exceldata").toString(), map.get("template").toString()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return R.ok("/priQuote/excel/" + filename); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public void exportLuckySheetXlsx(String newFileDir,String newFileName, String excelData) { | 
|---|
|  |  |  | public void exportLuckySheetXlsx(String newFileDir, String newFileName, String excelData, String template) { | 
|---|
|  |  |  | //解析对象,可以参照官方文档:https://mengshukeji.github.io/LuckysheetDocs/zh/guide/#%E6%95%B4%E4%BD%93%E7%BB%93%E6%9E%84 | 
|---|
|  |  |  | JSONArray jsonArray = (JSONArray) JSONObject.parse(excelData); | 
|---|
|  |  |  | //如果只有一个sheet那就是get(0),有多个那就对应取下标 | 
|---|
|  |  |  | JSONObject jsonObject = (JSONObject) jsonArray.get(0); | 
|---|
|  |  |  | JSONArray jsonObjectList = jsonObject.getJSONArray("celldata"); | 
|---|
|  |  |  | //excel模板路径 | 
|---|
|  |  |  | String filePath =  ClassUtils.getDefaultClassLoader().getResource("excel").getPath() + "/priQuoteTemplate.xlsx"; | 
|---|
|  |  |  | String filePath = ClassUtils.getDefaultClassLoader().getResource("excel").getPath() + "/priQuoteTemplate/data" + template +".xlsx"; | 
|---|
|  |  |  | //        String filePath = "/Users/ouyang/Downloads/uploadTestProductFile/生产日报表.xlsx"; | 
|---|
|  |  |  | File file = new File(filePath); | 
|---|
|  |  |  | FileInputStream in = null; | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String value = ""; | 
|---|
|  |  |  | if (jsonObjectValue != null && jsonObjectValue.get("v") != null){ | 
|---|
|  |  |  | if (jsonObjectValue != null && jsonObjectValue.get("v") != null) { | 
|---|
|  |  |  | //获取单元格值 | 
|---|
|  |  |  | value = jsonObjectValue.get("v").toString(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | if (Integer.parseInt(object.get("r").toString()) >= 4 && Integer.parseInt(object.get("r").toString()) <= 9) { | 
|---|
|  |  |  | if (Integer.parseInt(object.get("c").toString()) == 2 || Integer.parseInt(object.get("c").toString()) == 6) { | 
|---|
|  |  |  | //填充第二列数据 | 
|---|
|  |  |  | if (sheet.getRow((int) object.get("r")) !=null && sheet.getRow((int) object.get("r")).getCell((int) object.get("c")) != null){ | 
|---|
|  |  |  | if (sheet.getRow((int) object.get("r")) != null && sheet.getRow((int) object.get("r")).getCell((int) object.get("c")) != null) { | 
|---|
|  |  |  | if (!value.equals("")) { | 
|---|
|  |  |  | sheet.getRow((int) object.get("r")).getCell((int) object.get("c")).setCellValue(value); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | System.out.println("错误的=" + index + ">>>" + str_); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | case 3: | 
|---|
|  |  |  | case 4: | 
|---|
|  |  |  | case 5: | 
|---|
|  |  |  | if (sheet.getRow((int) object.get("r")) !=null && sheet.getRow((int) object.get("r")).getCell((int) object.get("c")) != null){ | 
|---|
|  |  |  | if (sheet.getRow((int) object.get("r")) != null && sheet.getRow((int) object.get("r")).getCell((int) object.get("c")) != null) { | 
|---|
|  |  |  | if (!value.equals("")) { | 
|---|
|  |  |  | sheet.getRow((int) object.get("r")).getCell((int) object.get("c")).setCellValue(value); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | System.out.println("错误的=" + index + ">>>" + str_); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case 2: | 
|---|
|  |  |  | // 查找规划组长 | 
|---|
|  |  |  | ProcessPermissions processPermissions = processPermissionsService.selectOne(new EntityWrapper<ProcessPermissions>().eq("process_memo", 2).eq("process", 3));//2:报价流程 | 
|---|
|  |  |  | ProcessPermissions processPermissions = processPermissionsService.selectOne(new EntityWrapper<ProcessPermissions>().eq("process_memo", 2).eq("process", "3-1"));//2:报价流程 | 
|---|
|  |  |  | User planLeader = userService.selectById(processPermissions.getUserId());       // 获取报价流程节点3确认人 | 
|---|
|  |  |  | if (Cools.isEmpty(planLeader)) { | 
|---|
|  |  |  | throw new CoolException("未查找到报价流程节点3确认人,请联系在审批权限添加确认人!"); | 
|---|
|  |  |  | throw new CoolException("未查找到报价流程节点3-1确认人,请联系在审批权限添加确认人!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!getUserId().equals(planLeader.getId())) { | 
|---|
|  |  |  | return R.error("抱歉,您没有审核的权限"); | 
|---|
|  |  |  | 
|---|
|  |  |  | //                } | 
|---|
|  |  |  | //                break; | 
|---|
|  |  |  | //            case 2: | 
|---|
|  |  |  | //                // 查找规划组长 | 
|---|
|  |  |  | //                User planLeader = userService.selectOne(new EntityWrapper<User>().eq("username","王开杰")); | 
|---|
|  |  |  | //                ProcessPermissions processPermissions = processPermissionsService.selectOne(new EntityWrapper<ProcessPermissions>().eq("process_memo", 2).eq("process", "3-1"));//2:报价流程 | 
|---|
|  |  |  | //                User planLeader = userService.selectById(processPermissions.getUserId());       // 获取报价流程节点3确认人 | 
|---|
|  |  |  | //                if (Cools.isEmpty(planLeader)) { | 
|---|
|  |  |  | //                    throw new CoolException("未查找总裁办,请联系管理员"); | 
|---|
|  |  |  | //                    throw new CoolException("未查找到报价流程节点3-1确认人,请联系在审批权限添加确认人!"); | 
|---|
|  |  |  | //                } | 
|---|
|  |  |  | //                if (!getUserId().equals(planLeader.getId())) { | 
|---|
|  |  |  | //                    return R.error("抱歉,您没有审核的权限"); | 
|---|