| | |
| | | @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.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); |
| | |
| | | priQuote.setDeptId(getDeptId()); |
| | | //更新时间 |
| | | priQuote.setUpdateTime(new Date()); |
| | | //模板 |
| | | priQuote.setTemplate(map.get("template").toString()); |
| | | |
| | | //业务员 |
| | | Plan plan = planService.selectById(priQuote.getItemId()); |
| | |
| | | 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; |