src/main/java/com/product/file/config/CmnConst.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/product/file/controller/DocumentDirectoryConstoller.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/product/file/service/DocumentDirectoryService.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/product/file/service/DocumentService.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
src/main/java/com/product/file/config/CmnConst.java
@@ -20,10 +20,10 @@ public static final String PRODUCT_SYS_CLIENTS = "product_sys_clients"; // 客户表 public static final String PRODUCT_SYS_ATTACHMENTS = "product_sys_attachments"; // 附件表 public static final String PRODUCT_SYS_DICT = "product_sys_dict"; public static final String product_oa_DIRECTORY = "product_oa_directory"; //文档目录表 public static final String product_oa_DIRECTORY_RIGHTS = "product_oa_directory_rights"; //文档目录权限表 public static final String product_oa_DOCUMENT = "product_oa_document"; //文档表 public static final String product_oa_DOCUMENT_LOG = "product_oa_document_log"; // 文档操作日志表 public static final String PRODUCT_OA_DIRECTORY = "product_oa_directory"; //文档目录表 public static final String PRODUCT_OA_DIRECTORY_RIGHTS = "product_oa_directory_rights"; //文档目录权限表 public static final String PRODUCT_OA_DOCUMENT = "product_oa_document"; //文档表 public static final String PRODUCT_OA_DOCUMENT_LOG = "product_oa_document_log"; // 文档操作日志表 public static final String PRODUCT_SYS_PRINT_TEMPLATE_RECORD = "product_sys_print_template_reocrd";// 打印模板记录表 public static final String PRODUCT_SYS_STAFFS = "product_sys_staffs"; public static final String TABLE_PRODUCT_SYS_ORG_LEVELS = "product_sys_org_levels";// 组织机构表 src/main/java/com/product/file/controller/DocumentDirectoryConstoller.java
@@ -15,6 +15,8 @@ import com.product.module.sys.config.SystemErrorCode; import com.product.module.sys.entity.SystemUser; import com.product.module.sys.version.ApiVersion; import com.product.util.BaseUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @@ -34,311 +36,369 @@ @RequestMapping("/api/directory") @RestController public class DocumentDirectoryConstoller extends AbstractBaseController { @Autowired public DocumentDirectoryService documentDirectoryService; @Autowired DocumentDirectoryService documentDirectoryService; /** * 数据权限验证 */ @Autowired PermissionService permissionService; /** * 新增文件夹数据 * @param request * @return */ @RequestMapping(value = "/addDocumentDirectory/{version}", method = RequestMethod.POST) @ApiVersion(1) public String addDocumentDirectory(HttpServletRequest request) { try { //获取参数 FieldSetEntity fse = null; Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA); if (bean != null) { RequestParameterEntity reqp = (RequestParameterEntity) bean; fse = reqp.getFormData(); } //判断参数是否为空 if (fse == null) { SpringMVCContextHolder.getSystemLogger().error(DocumentCode.DOCUMENT_FORM_NODATA.getValue(), DocumentCode.DOCUMENT_FORM_NODATA.getText()); return this.error(DocumentCode.DOCUMENT_FORM_NODATA.getValue(), DocumentCode.DOCUMENT_FORM_NODATA.getText()); } IDocumentDirectoryService service = (IDocumentDirectoryService)getProxyInstance(documentDirectoryService); return OK_Add(service.addDocumentDirectory(fse)); } catch (BaseException e) { SpringMVCContextHolder.getSystemLogger().error(e); return this.error(e); }catch (Exception e) { e.printStackTrace(); SpringMVCContextHolder.getSystemLogger().error(e); return this.error(DocumentCode.DOCUMENT_CATALOG_SAVE_FAIL.getValue(), DocumentCode.DOCUMENT_CATALOG_SAVE_FAIL.getText()); } } /** * 数据权限验证 */ @Autowired PermissionService permissionService; /** * 新增文件夹数据 * * @param request * @return */ @RequestMapping(value = "/all-directory-tree/{version}", method = RequestMethod.POST) @ApiVersion(1) public String allDirectoryTree(HttpServletRequest request) { try { // 获取参数 FieldSetEntity fse = BaseUtil.getFieldSetEntity(request, CmnConst.PRODUCT_OA_DIRECTORY); return com.product.util.ResultInfo.success(BaseUtil.dataTableEntityToJson(documentDirectoryService.allDirectoryTree())); } catch (BaseException e) { SpringMVCContextHolder.getSystemLogger().error(e); return this.error(e); } catch (Exception e) { e.printStackTrace(); SpringMVCContextHolder.getSystemLogger().error(e); return this.error(DocumentCode.DOCUMENT_CATALOG_SAVE_FAIL.getValue(), DocumentCode.DOCUMENT_CATALOG_SAVE_FAIL.getText()); } } /** * 修改文件夹 * @param request * @return */ @RequestMapping(value = "/upDocumentDirectory/{version}", method = RequestMethod.POST) @ApiVersion(1) public String upDocumentDirectory(HttpServletRequest request) { try { //获取参数 FieldSetEntity fse = null; Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA); if (bean != null) { RequestParameterEntity reqp = (RequestParameterEntity) bean; fse = reqp.getFormData(); } //判断参数是否为空 if (fse == null) { SpringMVCContextHolder .getSystemLogger().error(DocumentCode.DOCUMENT_FORM_NODATA.getValue(), DocumentCode.DOCUMENT_FORM_NODATA.getText()); return this.error(DocumentCode.DOCUMENT_FORM_NODATA.getValue(), DocumentCode.DOCUMENT_FORM_NODATA.getText()); } String uuid = fse.getString(CmnConst.UUID);//表uuid //超级管理员为1 普通单位管理员2 SystemUser currentUser = SpringMVCContextHolder.getCurrentUser(); int type; if(currentUser.getUserType() == 2){ type = CoreConst.DATA_PERMISSION_VALID_TYPE_ORG; }else { type = CoreConst.DATA_PERMISSION_VALID_TYPE_USER; } //数据操作的权限验证 if(!permissionService.validDataPermission(CmnConst.product_oa_DIRECTORY,uuid,type)) { SpringMVCContextHolder.getSystemLogger().error(SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getValue(), SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getText()); return this.error(SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getValue(), SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getText()); } IDocumentDirectoryService service = (IDocumentDirectoryService)getProxyInstance(documentDirectoryService); if(service.upDocumentDirectory(fse)) { return OK(); } return this.error(DocumentCode.DOCUMENT_CATALOG_SAVE_FAIL.getValue(), DocumentCode.DOCUMENT_CATALOG_SAVE_FAIL.getText()); } catch (BaseException e) { SpringMVCContextHolder.getSystemLogger().error(e); return this.error(e); }catch (Exception e) { e.printStackTrace(); SpringMVCContextHolder.getSystemLogger().error(e); return this.error(DocumentCode.DOCUMENT_CATALOG_SAVE_FAIL.getValue(), DocumentCode.DOCUMENT_CATALOG_SAVE_FAIL.getText()); } } /** * 新增文件夹数据 * * @param request * @return */ @RequestMapping(value = "/addDocumentDirectory/{version}", method = RequestMethod.POST) @ApiVersion(1) public String addDocumentDirectory(HttpServletRequest request) { try { // 获取参数 FieldSetEntity fse = null; Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA); if (bean != null) { RequestParameterEntity reqp = (RequestParameterEntity) bean; fse = reqp.getFormData(); } // 判断参数是否为空 if (fse == null) { SpringMVCContextHolder.getSystemLogger().error(DocumentCode.DOCUMENT_FORM_NODATA.getValue(), DocumentCode.DOCUMENT_FORM_NODATA.getText()); return this.error(DocumentCode.DOCUMENT_FORM_NODATA.getValue(), DocumentCode.DOCUMENT_FORM_NODATA.getText()); } IDocumentDirectoryService service = (IDocumentDirectoryService) getProxyInstance(documentDirectoryService); return OK_Add(service.addDocumentDirectory(fse)); } catch (BaseException e) { SpringMVCContextHolder.getSystemLogger().error(e); return this.error(e); } catch (Exception e) { e.printStackTrace(); SpringMVCContextHolder.getSystemLogger().error(e); return this.error(DocumentCode.DOCUMENT_CATALOG_SAVE_FAIL.getValue(), DocumentCode.DOCUMENT_CATALOG_SAVE_FAIL.getText()); } } /** * 个人文件夹重命名 * @param request * @return */ @RequestMapping(value = "/upDocumentDirectoryName/{version}", method = RequestMethod.POST) @ApiVersion(1) public String upDocumentDirectoryName(HttpServletRequest request) { try { //获取参数 FieldSetEntity fse = null; Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA); if (bean != null) { RequestParameterEntity reqp = (RequestParameterEntity) bean; fse = reqp.getFormData(); } //判断参数是否为空 if (fse == null) { SpringMVCContextHolder .getSystemLogger().error(DocumentCode.DOCUMENT_FORM_NODATA.getValue(), DocumentCode.DOCUMENT_FORM_NODATA.getText()); return this.error(DocumentCode.DOCUMENT_FORM_NODATA.getValue(), DocumentCode.DOCUMENT_FORM_NODATA.getText()); } String uuid = fse.getString(CmnConst.UUID);//表uuid //超级管理员为1 普通单位管理员2 SystemUser currentUser = SpringMVCContextHolder.getCurrentUser(); int type; if(currentUser.getUserType() == 2){ type = CoreConst.DATA_PERMISSION_VALID_TYPE_ORG; }else { type = CoreConst.DATA_PERMISSION_VALID_TYPE_USER; } //数据操作的权限验证 if(!permissionService.validDataPermission(CmnConst.product_oa_DIRECTORY,uuid,type)) { SpringMVCContextHolder.getSystemLogger().error(SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getValue(), SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getText()); return this.error(SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getValue(), SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getText()); } IDocumentDirectoryService service = (IDocumentDirectoryService)getProxyInstance(documentDirectoryService); if(service.upDocumentDirectoryName(fse)) { return OK(); } return this.error(DocumentCode.DOCUMENT_DIRECTORY_NAME_FAIL.getValue(), DocumentCode.DOCUMENT_DIRECTORY_NAME_FAIL.getText()); } catch (BaseException e) { SpringMVCContextHolder.getSystemLogger().error(e); return this.error(e); }catch (Exception e) { e.printStackTrace(); SpringMVCContextHolder.getSystemLogger().error(e); return this.error(DocumentCode.DOCUMENT_DIRECTORY_NAME_FAIL.getValue(), DocumentCode.DOCUMENT_DIRECTORY_NAME_FAIL.getText()); } } /** * 修改文件夹 * * @param request * @return */ @RequestMapping(value = "/upDocumentDirectory/{version}", method = RequestMethod.POST) @ApiVersion(1) public String upDocumentDirectory(HttpServletRequest request) { try { // 获取参数 FieldSetEntity fse = null; Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA); if (bean != null) { RequestParameterEntity reqp = (RequestParameterEntity) bean; fse = reqp.getFormData(); } // 判断参数是否为空 if (fse == null) { SpringMVCContextHolder.getSystemLogger().error(DocumentCode.DOCUMENT_FORM_NODATA.getValue(), DocumentCode.DOCUMENT_FORM_NODATA.getText()); return this.error(DocumentCode.DOCUMENT_FORM_NODATA.getValue(), DocumentCode.DOCUMENT_FORM_NODATA.getText()); } String uuid = fse.getString(CmnConst.UUID);// 表uuid // 超级管理员为1 普通单位管理员2 SystemUser currentUser = SpringMVCContextHolder.getCurrentUser(); int type; if (currentUser.getUserType() == 2) { type = CoreConst.DATA_PERMISSION_VALID_TYPE_ORG; } else { type = CoreConst.DATA_PERMISSION_VALID_TYPE_USER; } // 数据操作的权限验证 if (!permissionService.validDataPermission(CmnConst.PRODUCT_OA_DIRECTORY, uuid, type)) { SpringMVCContextHolder.getSystemLogger().error(SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getValue(), SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getText()); return this.error(SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getValue(), SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getText()); } IDocumentDirectoryService service = (IDocumentDirectoryService) getProxyInstance(documentDirectoryService); if (service.upDocumentDirectory(fse)) { return OK(); } return this.error(DocumentCode.DOCUMENT_CATALOG_SAVE_FAIL.getValue(), DocumentCode.DOCUMENT_CATALOG_SAVE_FAIL.getText()); } catch (BaseException e) { SpringMVCContextHolder.getSystemLogger().error(e); return this.error(e); } catch (Exception e) { e.printStackTrace(); SpringMVCContextHolder.getSystemLogger().error(e); return this.error(DocumentCode.DOCUMENT_CATALOG_SAVE_FAIL.getValue(), DocumentCode.DOCUMENT_CATALOG_SAVE_FAIL.getText()); } } /** * 删除文件夹 * @param request * @return */ @RequestMapping(value = "/delDocumentDirectory/{version}", method = RequestMethod.POST) @ApiVersion(1) public String delDocumentDirectory(HttpServletRequest request) { try { //获取参数 FieldSetEntity fse = null; Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA); if (bean != null) { RequestParameterEntity reqp = (RequestParameterEntity) bean; fse = reqp.getFormData(); } //判断参数是否为空 if (fse == null) { SpringMVCContextHolder .getSystemLogger().error(DocumentCode.DOCUMENT_FORM_NODATA.getValue(), DocumentCode.DOCUMENT_FORM_NODATA.getText()); return this.error(DocumentCode.DOCUMENT_FORM_NODATA.getValue(), DocumentCode.DOCUMENT_FORM_NODATA.getText()); } String uuid = fse.getString(CmnConst.UUID);//表uuid //超级管理员为1 普通单位管理员2 SystemUser currentUser = SpringMVCContextHolder.getCurrentUser(); int type; if(currentUser.getUserType() == 2){ type = CoreConst.DATA_PERMISSION_VALID_TYPE_ORG; }else { type = CoreConst.DATA_PERMISSION_VALID_TYPE_USER; } //数据操作的权限验证 if(!permissionService.validDataPermission(CmnConst.product_oa_DIRECTORY,uuid,type)) { SpringMVCContextHolder.getSystemLogger().error(SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getValue(), SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getText()); return this.error(SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getValue(), SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getText()); } IDocumentDirectoryService service = (IDocumentDirectoryService)getProxyInstance(documentDirectoryService); if(service.delDocumentDirectory(fse)){ return OK(); } return this.error(DocumentCode.DOCUMENT_CATALOG_DELETE_FAIL.getValue(), DocumentCode.DOCUMENT_CATALOG_DELETE_FAIL.getText()); } catch (BaseException e) { SpringMVCContextHolder.getSystemLogger().error(e); return this.error(e); }catch (Exception e) { e.printStackTrace(); SpringMVCContextHolder.getSystemLogger().error(e); return this.error(DocumentCode.DOCUMENT_CATALOG_DELETE_FAIL.getValue(), DocumentCode.DOCUMENT_CATALOG_DELETE_FAIL.getText()); } } /** * 个人文件夹重命名 * * @param request * @return */ @RequestMapping(value = "/upDocumentDirectoryName/{version}", method = RequestMethod.POST) @ApiVersion(1) public String upDocumentDirectoryName(HttpServletRequest request) { try { // 获取参数 FieldSetEntity fse = null; Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA); if (bean != null) { RequestParameterEntity reqp = (RequestParameterEntity) bean; fse = reqp.getFormData(); } // 判断参数是否为空 if (fse == null) { SpringMVCContextHolder.getSystemLogger().error(DocumentCode.DOCUMENT_FORM_NODATA.getValue(), DocumentCode.DOCUMENT_FORM_NODATA.getText()); return this.error(DocumentCode.DOCUMENT_FORM_NODATA.getValue(), DocumentCode.DOCUMENT_FORM_NODATA.getText()); } String uuid = fse.getString(CmnConst.UUID);// 表uuid // 超级管理员为1 普通单位管理员2 SystemUser currentUser = SpringMVCContextHolder.getCurrentUser(); int type; if (currentUser.getUserType() == 2) { type = CoreConst.DATA_PERMISSION_VALID_TYPE_ORG; } else { type = CoreConst.DATA_PERMISSION_VALID_TYPE_USER; } // 数据操作的权限验证 if (!permissionService.validDataPermission(CmnConst.PRODUCT_OA_DIRECTORY, uuid, type)) { SpringMVCContextHolder.getSystemLogger().error(SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getValue(), SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getText()); return this.error(SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getValue(), SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getText()); } IDocumentDirectoryService service = (IDocumentDirectoryService) getProxyInstance(documentDirectoryService); if (service.upDocumentDirectoryName(fse)) { return OK(); } return this.error(DocumentCode.DOCUMENT_DIRECTORY_NAME_FAIL.getValue(), DocumentCode.DOCUMENT_DIRECTORY_NAME_FAIL.getText()); } catch (BaseException e) { SpringMVCContextHolder.getSystemLogger().error(e); return this.error(e); } catch (Exception e) { e.printStackTrace(); SpringMVCContextHolder.getSystemLogger().error(e); return this.error(DocumentCode.DOCUMENT_DIRECTORY_NAME_FAIL.getValue(), DocumentCode.DOCUMENT_DIRECTORY_NAME_FAIL.getText()); } } /** * 删除文件夹 * * @param request * @return */ @RequestMapping(value = "/delDocumentDirectory/{version}", method = RequestMethod.POST) @ApiVersion(1) public String delDocumentDirectory(HttpServletRequest request) { try { // 获取参数 FieldSetEntity fse = null; Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA); if (bean != null) { RequestParameterEntity reqp = (RequestParameterEntity) bean; fse = reqp.getFormData(); } // 判断参数是否为空 if (fse == null) { SpringMVCContextHolder.getSystemLogger().error(DocumentCode.DOCUMENT_FORM_NODATA.getValue(), DocumentCode.DOCUMENT_FORM_NODATA.getText()); return this.error(DocumentCode.DOCUMENT_FORM_NODATA.getValue(), DocumentCode.DOCUMENT_FORM_NODATA.getText()); } String uuid = fse.getString(CmnConst.UUID);// 表uuid // 超级管理员为1 普通单位管理员2 SystemUser currentUser = SpringMVCContextHolder.getCurrentUser(); int type; if (currentUser.getUserType() == 2) { type = CoreConst.DATA_PERMISSION_VALID_TYPE_ORG; } else { type = CoreConst.DATA_PERMISSION_VALID_TYPE_USER; } // 数据操作的权限验证 if (!permissionService.validDataPermission(CmnConst.PRODUCT_OA_DIRECTORY, uuid, type)) { SpringMVCContextHolder.getSystemLogger().error(SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getValue(), SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getText()); return this.error(SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getValue(), SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getText()); } IDocumentDirectoryService service = (IDocumentDirectoryService) getProxyInstance(documentDirectoryService); if (service.delDocumentDirectory(fse)) { return OK(); } return this.error(DocumentCode.DOCUMENT_CATALOG_DELETE_FAIL.getValue(), DocumentCode.DOCUMENT_CATALOG_DELETE_FAIL.getText()); } catch (BaseException e) { SpringMVCContextHolder.getSystemLogger().error(e); return this.error(e); } catch (Exception e) { e.printStackTrace(); SpringMVCContextHolder.getSystemLogger().error(e); return this.error(DocumentCode.DOCUMENT_CATALOG_DELETE_FAIL.getValue(), DocumentCode.DOCUMENT_CATALOG_DELETE_FAIL.getText()); } } /** * 文件目录列表展示 * @param request * @return */ @RequestMapping(value = "/moveToList/{version}", method = RequestMethod.POST) @ApiVersion(1) public String moveToList(HttpServletRequest request) { try { //获取参数 FieldSetEntity fse = null; Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA); if (bean != null) { RequestParameterEntity reqp = (RequestParameterEntity) bean; fse = reqp.getFormData(); } //判断参数是否为空 if (fse == null) { SpringMVCContextHolder .getSystemLogger().error(DocumentCode.DOCUMENT_FORM_NODATA.getValue(), DocumentCode.DOCUMENT_FORM_NODATA.getText()); return this.error(DocumentCode.DOCUMENT_FORM_NODATA.getValue(), DocumentCode.DOCUMENT_FORM_NODATA.getText()); } return OK_List(documentDirectoryService.moveToList(fse)); } catch (BaseException e) { SpringMVCContextHolder.getSystemLogger().error(e); return this.error(e); }catch (Exception e) { e.printStackTrace(); SpringMVCContextHolder.getSystemLogger().error(e); return this.error(DocumentCode.DOCUMENT_CATALOG_GET_FAIL.getValue(), DocumentCode.DOCUMENT_CATALOG_GET_FAIL.getText()); } } /** * 文件目录列表展示 * * @param request * @return */ @RequestMapping(value = "/moveToList/{version}", method = RequestMethod.POST) @ApiVersion(1) public String moveToList(HttpServletRequest request) { try { // 获取参数 FieldSetEntity fse = null; Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA); if (bean != null) { RequestParameterEntity reqp = (RequestParameterEntity) bean; fse = reqp.getFormData(); } // 判断参数是否为空 if (fse == null) { SpringMVCContextHolder.getSystemLogger().error(DocumentCode.DOCUMENT_FORM_NODATA.getValue(), DocumentCode.DOCUMENT_FORM_NODATA.getText()); return this.error(DocumentCode.DOCUMENT_FORM_NODATA.getValue(), DocumentCode.DOCUMENT_FORM_NODATA.getText()); } return OK_List(documentDirectoryService.moveToList(fse)); } catch (BaseException e) { SpringMVCContextHolder.getSystemLogger().error(e); return this.error(e); } catch (Exception e) { e.printStackTrace(); SpringMVCContextHolder.getSystemLogger().error(e); return this.error(DocumentCode.DOCUMENT_CATALOG_GET_FAIL.getValue(), DocumentCode.DOCUMENT_CATALOG_GET_FAIL.getText()); } } /** * 获取文档目录树形列表 * * @param request * @return */ @RequestMapping(value = "/treeListAll/{version}", method = RequestMethod.POST) @ApiVersion(1) public String treeListAll(HttpServletRequest request) { try { // 获取参数 FieldSetEntity fse = null; Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA); if (bean != null) { RequestParameterEntity reqp = (RequestParameterEntity) bean; fse = reqp.getFormData(); } // 判断参数是否为空 if (fse == null) { SpringMVCContextHolder.getSystemLogger().error(DocumentCode.DOCUMENT_FORM_NODATA.getValue(), DocumentCode.DOCUMENT_FORM_NODATA.getText()); return this.error(DocumentCode.DOCUMENT_FORM_NODATA.getValue(), DocumentCode.DOCUMENT_FORM_NODATA.getText()); } return ResultInfo.success(documentDirectoryService.treeListAll(fse)); } catch (BaseException e) { SpringMVCContextHolder.getSystemLogger().error(e); return this.error(e); } catch (Exception e) { e.printStackTrace(); SpringMVCContextHolder.getSystemLogger().error(e); return this.error(DocumentCode.DOCUMENT_CATALOG_GET_TREE_FAIL.getValue(), DocumentCode.DOCUMENT_CATALOG_GET_TREE_FAIL.getText()); } } /** * 获取文档目录树形列表 * @param request * @return */ @RequestMapping(value = "/treeListAll/{version}", method = RequestMethod.POST) @ApiVersion(1) public String treeListAll(HttpServletRequest request) { try { //获取参数 FieldSetEntity fse = null; Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA); if (bean != null) { RequestParameterEntity reqp = (RequestParameterEntity) bean; fse = reqp.getFormData(); } //判断参数是否为空 if (fse == null) { SpringMVCContextHolder .getSystemLogger().error(DocumentCode.DOCUMENT_FORM_NODATA.getValue(), DocumentCode.DOCUMENT_FORM_NODATA.getText()); return this.error(DocumentCode.DOCUMENT_FORM_NODATA.getValue(), DocumentCode.DOCUMENT_FORM_NODATA.getText()); } return ResultInfo.success(documentDirectoryService.treeListAll(fse)); } catch (BaseException e) { SpringMVCContextHolder.getSystemLogger().error(e); return this.error(e); }catch (Exception e) { e.printStackTrace(); SpringMVCContextHolder.getSystemLogger().error(e); return this.error(DocumentCode.DOCUMENT_CATALOG_GET_TREE_FAIL.getValue(), DocumentCode.DOCUMENT_CATALOG_GET_TREE_FAIL.getText()); } } /** * 获取文档目录详情 * @param request * @return */ @RequestMapping(value = "/documentDirectoryInfo/{version}", method = RequestMethod.POST) @ApiVersion(1) public String documentDirectoryInfo(HttpServletRequest request) { try { //获取参数 FieldSetEntity fse = null; Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA); if (bean != null) { RequestParameterEntity reqp = (RequestParameterEntity) bean; fse = reqp.getFormData(); } //判断参数是否为空 if (fse == null) { SpringMVCContextHolder .getSystemLogger().error(DocumentCode.DOCUMENT_FORM_NODATA.getValue(), DocumentCode.DOCUMENT_FORM_NODATA.getText()); return this.error(DocumentCode.DOCUMENT_FORM_NODATA.getValue(), DocumentCode.DOCUMENT_FORM_NODATA.getText()); } String uuid = fse.getString(CmnConst.UUID);//表uuid //超级管理员为1 普通单位管理员2 SystemUser currentUser = SpringMVCContextHolder.getCurrentUser(); int type; if(currentUser.getUserType() == 2){ type = CoreConst.DATA_PERMISSION_VALID_TYPE_ORG; }else { type = CoreConst.DATA_PERMISSION_VALID_TYPE_USER; } //数据操作的权限验证 if(!permissionService.validDataPermission(CmnConst.product_oa_DIRECTORY,uuid,type)) { SpringMVCContextHolder.getSystemLogger().error(SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getValue(), SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getText()); return this.error(SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getValue(), SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getText()); } return OK_List(documentDirectoryService.documentDirectoryInfo(fse)); } catch (BaseException e) { SpringMVCContextHolder.getSystemLogger().error(e); return this.error(e); }catch (Exception e) { e.printStackTrace(); SpringMVCContextHolder.getSystemLogger().error(e); return this.error(DocumentCode.DOCUMENT_CATALOG_GET_FAIL.getValue(), DocumentCode.DOCUMENT_CATALOG_GET_FAIL.getText()); } } /** * 获取文档目录详情 * * @param request * @return */ @RequestMapping(value = "/documentDirectoryInfo/{version}", method = RequestMethod.POST) @ApiVersion(1) public String documentDirectoryInfo(HttpServletRequest request) { try { // 获取参数 FieldSetEntity fse = null; Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA); if (bean != null) { RequestParameterEntity reqp = (RequestParameterEntity) bean; fse = reqp.getFormData(); } // 判断参数是否为空 if (fse == null) { SpringMVCContextHolder.getSystemLogger().error(DocumentCode.DOCUMENT_FORM_NODATA.getValue(), DocumentCode.DOCUMENT_FORM_NODATA.getText()); return this.error(DocumentCode.DOCUMENT_FORM_NODATA.getValue(), DocumentCode.DOCUMENT_FORM_NODATA.getText()); } String uuid = fse.getString(CmnConst.UUID);// 表uuid // 超级管理员为1 普通单位管理员2 SystemUser currentUser = SpringMVCContextHolder.getCurrentUser(); int type; if (currentUser.getUserType() == 2) { type = CoreConst.DATA_PERMISSION_VALID_TYPE_ORG; } else { type = CoreConst.DATA_PERMISSION_VALID_TYPE_USER; } // 数据操作的权限验证 if (!permissionService.validDataPermission(CmnConst.PRODUCT_OA_DIRECTORY, uuid, type)) { SpringMVCContextHolder.getSystemLogger().error(SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getValue(), SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getText()); return this.error(SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getValue(), SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getText()); } return OK_List(documentDirectoryService.documentDirectoryInfo(fse)); } catch (BaseException e) { SpringMVCContextHolder.getSystemLogger().error(e); return this.error(e); } catch (Exception e) { e.printStackTrace(); SpringMVCContextHolder.getSystemLogger().error(e); return this.error(DocumentCode.DOCUMENT_CATALOG_GET_FAIL.getValue(), DocumentCode.DOCUMENT_CATALOG_GET_FAIL.getText()); } } } src/main/java/com/product/file/service/DocumentDirectoryService.java
@@ -35,249 +35,270 @@ @Component public class DocumentDirectoryService extends AbstractBaseService implements IDocumentDirectoryService { @Autowired public BaseDao baseDao; @Autowired public DocumentDirectoryService documentDirectoryService; @Autowired public BaseDao baseDao; @Autowired public DocumentDirectoryService documentDirectoryService; /** * 单位文件夹树 * @return */ public DataTableEntity allDirectoryTree() { DataTableEntity dtTree = baseDao.listTable(CmnConst.PRODUCT_OA_DIRECTORY, "directory_type = 1"); if (!BaseUtil.dataTableIsEmpty(dtTree)) { return BaseUtil.dataTableToTreeTable(dtTree, CmnConst.TRICODE, CmnConst.TRICODE_PARENT, null); } return dtTree; } @Override @Transactional public String addDocumentDirectory(FieldSetEntity fieldSetEntity) throws BaseException { @Override @Transactional public String addDocumentDirectory(FieldSetEntity fieldSetEntity) throws BaseException { String triCode = CodeUtil.getNewCodeByTemp(CmnConst.product_oa_DIRECTORY,CmnConst.TRICODE,!StringUtils.isEmpty(fieldSetEntity.getString(CmnConst.TRICODE_PARENT))?fieldSetEntity.getString(CmnConst.TRICODE_PARENT):""); fieldSetEntity.setValue(CmnConst.TRICODE,triCode); String[] codes = triCode.split("-"); String org_level_uuid = SpringMVCContextHolder.getCurrentUser().getOrg_level_uuid(); fieldSetEntity.setValue(CmnConst.ORG_LEVEL_UUID,org_level_uuid); fieldSetEntity.setValue(CmnConst.DIRECTORY_TIER,codes.length); fieldSetEntity.setValue(CmnConst.CREATED_BY, SpringMVCContextHolder.getCurrentUser().getUser_id());// 获取登录帐号 fieldSetEntity.setValue(CmnConst.CREATED_UTC_DATETIME, DateUtils.getDateTime());// 创建时间 return baseDao.add(fieldSetEntity); } String triCode = CodeUtil.getNewCodeByTemp(CmnConst.PRODUCT_OA_DIRECTORY, CmnConst.TRICODE, !StringUtils.isEmpty(fieldSetEntity.getString(CmnConst.TRICODE_PARENT)) ? fieldSetEntity.getString(CmnConst.TRICODE_PARENT) : ""); fieldSetEntity.setValue(CmnConst.TRICODE, triCode); String[] codes = triCode.split("-"); String org_level_uuid = SpringMVCContextHolder.getCurrentUser().getOrg_level_uuid(); fieldSetEntity.setValue(CmnConst.ORG_LEVEL_UUID, org_level_uuid); fieldSetEntity.setValue(CmnConst.DIRECTORY_TIER, codes.length); fieldSetEntity.setValue(CmnConst.CREATED_BY, SpringMVCContextHolder.getCurrentUser().getUser_id());// 获取登录帐号 fieldSetEntity.setValue(CmnConst.CREATED_UTC_DATETIME, DateUtils.getDateTime());// 创建时间 return baseDao.add(fieldSetEntity); } @Override @Transactional public boolean upDocumentDirectory(FieldSetEntity fieldSetEntity) throws BaseException { String uuid = fieldSetEntity.getString(CmnConst.UUID); FieldSetEntity fieldSet = baseDao.getFieldSetEntity(CmnConst.product_oa_DIRECTORY, uuid, false); String tricode_parent1 = fieldSetEntity.getString(CmnConst.TRICODE_PARENT); String tricode_parent2 = fieldSet.getString(CmnConst.TRICODE_PARENT); boolean flag; //上级目录tricode如果不相等 if(!StringUtils.isEmpty(tricode_parent1) || !StringUtils.isEmpty(tricode_parent2)) { if (!StringUtils.isEmpty(tricode_parent1) && !StringUtils.isEmpty(tricode_parent2) && !tricode_parent1.equals(tricode_parent2)) { flag = true; }else if(!StringUtils.isEmpty(tricode_parent1) && !StringUtils.isEmpty(tricode_parent2) && tricode_parent1.equals(tricode_parent2)){ flag = false; }else if(!StringUtils.isEmpty(tricode_parent1) && StringUtils.isEmpty(tricode_parent2)){ tricode_parent2 = ""; flag = true; }else if (!StringUtils.isEmpty(tricode_parent2) && StringUtils.isEmpty(tricode_parent1)){ tricode_parent1 = ""; flag = true; }else { flag = false; } }else { flag = false; } @Override @Transactional public boolean upDocumentDirectory(FieldSetEntity fieldSetEntity) throws BaseException { String uuid = fieldSetEntity.getString(CmnConst.UUID); FieldSetEntity fieldSet = baseDao.getFieldSetEntity(CmnConst.PRODUCT_OA_DIRECTORY, uuid, false); String tricode_parent1 = fieldSetEntity.getString(CmnConst.TRICODE_PARENT); String tricode_parent2 = fieldSet.getString(CmnConst.TRICODE_PARENT); boolean flag; // 上级目录tricode如果不相等 if (!StringUtils.isEmpty(tricode_parent1) || !StringUtils.isEmpty(tricode_parent2)) { if (!StringUtils.isEmpty(tricode_parent1) && !StringUtils.isEmpty(tricode_parent2) && !tricode_parent1.equals(tricode_parent2)) { flag = true; } else if (!StringUtils.isEmpty(tricode_parent1) && !StringUtils.isEmpty(tricode_parent2) && tricode_parent1.equals(tricode_parent2)) { flag = false; } else if (!StringUtils.isEmpty(tricode_parent1) && StringUtils.isEmpty(tricode_parent2)) { tricode_parent2 = ""; flag = true; } else if (!StringUtils.isEmpty(tricode_parent2) && StringUtils.isEmpty(tricode_parent1)) { tricode_parent1 = ""; flag = true; } else { flag = false; } } else { flag = false; } if(flag){ StringBuffer sql=new StringBuffer() ; sql.append(" update product_oa_directory set tricode=replace("); sql.append(" tricode,concat(?,'-'),concat(?,'-')),"); sql.append(" tricode_parent=(case when tricode_parent=? then replace(tricode_parent,?,?) else "); sql.append(" replace (tricode_parent,concat(?,'-'),concat(?,'-')) end )"); sql.append(" where tricode like ?"); baseDao.executeUpdate(sql.toString(), new String[]{ tricode_parent1, tricode_parent2, tricode_parent1, tricode_parent1, tricode_parent2, tricode_parent1, tricode_parent2, tricode_parent1+"-%", }); } if (flag) { StringBuffer sql = new StringBuffer(); sql.append(" update PRODUCT_OA_directory set tricode=replace("); sql.append(" tricode,concat(?,'-'),concat(?,'-')),"); sql.append(" tricode_parent=(case when tricode_parent=? then replace(tricode_parent,?,?) else "); sql.append(" replace (tricode_parent,concat(?,'-'),concat(?,'-')) end )"); sql.append(" where tricode like ?"); baseDao.executeUpdate(sql.toString(), new String[] { tricode_parent1, tricode_parent2, tricode_parent1, tricode_parent1, tricode_parent2, tricode_parent1, tricode_parent2, tricode_parent1 + "-%", }); } fieldSetEntity.setValue(CmnConst.UPDATED_BY, SpringMVCContextHolder.getCurrentUser().getUser_id());// 获取登录帐号 fieldSetEntity.setValue(CmnConst.UPDATED_UTC_DATETIME, DateUtils.getDateTime());// 创建时间 return baseDao.update(fieldSetEntity); } fieldSetEntity.setValue(CmnConst.UPDATED_BY, SpringMVCContextHolder.getCurrentUser().getUser_id());// 获取登录帐号 fieldSetEntity.setValue(CmnConst.UPDATED_UTC_DATETIME, DateUtils.getDateTime());// 创建时间 return baseDao.update(fieldSetEntity); } @Override @Transactional public boolean delDocumentDirectory(FieldSetEntity fieldSetEntity) throws BaseException { String uuid = fieldSetEntity.getString(CmnConst.UUID); String directory_type = fieldSetEntity.getString(CmnConst.DIRECTORY_TYPE); String filter = ""; if("2".equals(directory_type)){ filter = " AND " + "created_by = " + SpringMVCContextHolder.getCurrentUserId(); } DataTableEntity dataTableEntity = baseDao.listTable("SELECT * FROM product_oa_directory WHERE directory_type = ? AND tricode_parent = (SELECT tricode FROM product_oa_directory where uuid = ?)" + filter, new String[]{directory_type,uuid}); if(BaseUtil.dataTableIsEmpty(dataTableEntity)){ baseDao.delete(CmnConst.product_oa_DOCUMENT, "directory_uuid = ?", new String[]{uuid}); return baseDao.delete(CmnConst.product_oa_DIRECTORY, new String[]{uuid}); }else { throw new BaseException(DocumentCode.DOCUMENT_CATALOG_DELETE_FAIL.getValue(), DocumentCode.DOCUMENT_CATALOG_DELETE_FAIL.getText(), this.getClass(),"public boolean delDocumentDirectory(FieldSetEntity fieldSetEntity) throws BaseException"); } } @Override @Transactional public boolean delDocumentDirectory(FieldSetEntity fieldSetEntity) throws BaseException { String uuid = fieldSetEntity.getString(CmnConst.UUID); String directory_type = fieldSetEntity.getString(CmnConst.DIRECTORY_TYPE); String filter = ""; if ("2".equals(directory_type)) { filter = " AND " + "created_by = " + SpringMVCContextHolder.getCurrentUserId(); } DataTableEntity dataTableEntity = baseDao.listTable( "SELECT * FROM PRODUCT_OA_directory WHERE directory_type = ? AND tricode_parent = (SELECT tricode FROM PRODUCT_OA_directory where uuid = ?)" + filter, new String[] { directory_type, uuid }); if (BaseUtil.dataTableIsEmpty(dataTableEntity)) { baseDao.delete(CmnConst.PRODUCT_OA_DOCUMENT, "directory_uuid = ?", new String[] { uuid }); return baseDao.delete(CmnConst.PRODUCT_OA_DIRECTORY, new String[] { uuid }); } else { throw new BaseException(DocumentCode.DOCUMENT_CATALOG_DELETE_FAIL.getValue(), DocumentCode.DOCUMENT_CATALOG_DELETE_FAIL.getText(), this.getClass(), "public boolean delDocumentDirectory(FieldSetEntity fieldSetEntity) throws BaseException"); } } /** * 获取当前文件路径 * @param fieldSetEntity * @return * @throws BaseException */ @Override public DataTableEntity getDirectoryStructure(FieldSetEntity fieldSetEntity) throws BaseException { String uuid = fieldSetEntity.getString(CmnConst.DIRECTORY_UUID); fieldSetEntity = baseDao.getFieldSetEntity(CmnConst.product_oa_DIRECTORY, uuid, false); String triCode = fieldSetEntity.getString(CmnConst.TRICODE); String type = fieldSetEntity.getString(CmnConst.DIRECTORY_TYPE); List<String> codeList = ListUtils.newArrayList(); //拆分为上级目录 if(triCode.indexOf('-') != -1) { do { codeList.add(0, triCode); triCode = triCode.substring(0, triCode.lastIndexOf('-')); } while (triCode.indexOf('-') != -1); codeList.add(0,triCode); }else { codeList.add(triCode); } SystemUser user = SpringMVCContextHolder.getCurrentUser(); DataTableEntity dataTableEntity; //单位文件夹 if("1".equals(type)){ codeList.add(0,user.getOrg_level_uuid()); dataTableEntity = baseDao.listTable(CmnConst.product_oa_DIRECTORY,"directory_type = 1 AND org_level_uuid = ? AND "+BaseUtil.buildQuestionMarkFilter(CmnConst.TRICODE,codeList.size()-1,true),codeList.toArray(),"tricode"); //个人文件夹 }else { codeList.add(0,String.valueOf(user.getUser_id())); dataTableEntity = baseDao.listTable(CmnConst.product_oa_DIRECTORY,"directory_type = 2 AND created_by = ? AND "+BaseUtil.buildQuestionMarkFilter(CmnConst.TRICODE,codeList.size()-1,true),codeList.toArray(),"tricode"); } baseDao.listInternationDataTable(dataTableEntity, null); return dataTableEntity; } /** * 获取当前文件路径 * * @param fieldSetEntity * @return * @throws BaseException */ @Override public DataTableEntity getDirectoryStructure(FieldSetEntity fieldSetEntity) throws BaseException { String uuid = fieldSetEntity.getString(CmnConst.DIRECTORY_UUID); fieldSetEntity = baseDao.getFieldSetEntity(CmnConst.PRODUCT_OA_DIRECTORY, uuid, false); String triCode = fieldSetEntity.getString(CmnConst.TRICODE); String type = fieldSetEntity.getString(CmnConst.DIRECTORY_TYPE); List<String> codeList = ListUtils.newArrayList(); // 拆分为上级目录 if (triCode.indexOf('-') != -1) { do { codeList.add(0, triCode); triCode = triCode.substring(0, triCode.lastIndexOf('-')); } while (triCode.indexOf('-') != -1); codeList.add(0, triCode); } else { codeList.add(triCode); } SystemUser user = SpringMVCContextHolder.getCurrentUser(); DataTableEntity dataTableEntity; // 单位文件夹 if ("1".equals(type)) { codeList.add(0, user.getOrg_level_uuid()); dataTableEntity = baseDao.listTable(CmnConst.PRODUCT_OA_DIRECTORY, "directory_type = 1 AND org_level_uuid = ? AND " + BaseUtil.buildQuestionMarkFilter(CmnConst.TRICODE, codeList.size() - 1, true), codeList.toArray(), "tricode"); // 个人文件夹 } else { codeList.add(0, String.valueOf(user.getUser_id())); dataTableEntity = baseDao.listTable(CmnConst.PRODUCT_OA_DIRECTORY, "directory_type = 2 AND created_by = ? AND " + BaseUtil.buildQuestionMarkFilter(CmnConst.TRICODE, codeList.size() - 1, true), codeList.toArray(), "tricode"); } baseDao.listInternationDataTable(dataTableEntity, null); return dataTableEntity; } @Override public JSONArray treeListAll(FieldSetEntity fieldSetEntity) throws BaseException { // 关联公司uuid String directory_type = fieldSetEntity.getString(CmnConst.DIRECTORY_TYPE); // 公司文件夹 DataTableEntity data; SystemUser user = SpringMVCContextHolder.getCurrentUser(); StringBuffer sql = new StringBuffer(); sql.append("SELECT a.*,ifnull(b.number,0) number FROM PRODUCT_OA_directory a LEFT JOIN "); sql.append( "(SELECT COUNT(*) number,directory_uuid FROM PRODUCT_OA_document GROUP BY directory_uuid) b on a.uuid=b.directory_uuid "); @Override public JSONArray treeListAll(FieldSetEntity fieldSetEntity) throws BaseException { //关联公司uuid String directory_type = fieldSetEntity.getString(CmnConst.DIRECTORY_TYPE); //公司文件夹 DataTableEntity data; SystemUser user = SpringMVCContextHolder.getCurrentUser(); StringBuffer sql = new StringBuffer(); sql.append("SELECT a.*,ifnull(b.number,0) number FROM product_oa_directory a LEFT JOIN "); sql.append("(SELECT COUNT(*) number,directory_uuid FROM product_oa_document GROUP BY directory_uuid) b on a.uuid=b.directory_uuid "); if ("1".equals(directory_type)) { String org_level_uuid = user.getOrg_level_uuid(); sql.append("where directory_type = 1 AND org_level_uuid = ? "); data = baseDao.listTable(sql.toString(), new Object[] { org_level_uuid }); // data = baseDao.listTable(CmnConst.PRODUCT_OA_DIRECTORY, " directory_type = 1 AND org_level_uuid = ?", new String[]{org_level_uuid}, "tricode"); // 个人文件夹 } else { Integer userId = user.getUser_id(); sql.append("where directory_type = 2 AND created_by = ? "); data = baseDao.listTable(sql.toString(), new Object[] { userId }); if("1".equals(directory_type)){ String org_level_uuid = user.getOrg_level_uuid(); sql.append("where directory_type = 1 AND org_level_uuid = ? "); data = baseDao.listTable(sql.toString(), new Object[]{org_level_uuid}); // data = baseDao.listTable(CmnConst.product_oa_DIRECTORY, " directory_type = 1 AND org_level_uuid = ?", new String[]{org_level_uuid}, "tricode"); //个人文件夹 }else { Integer userId = user.getUser_id(); sql.append("where directory_type = 2 AND created_by = ? "); data = baseDao.listTable(sql.toString(), new Object[]{userId}); // data = baseDao.listTable(CmnConst.PRODUCT_OA_DIRECTORY, " directory_type = 2 AND created_by = ?", new Object[]{userId}, "tricode"); } baseDao.listInternationDataTable(data, null); JSONArray menus = this.encapsulationTree(data); // 获取当前公司 JSONObject orgLevelInfo = new JSONObject(); orgLevelInfo.put("directory_name", user.getOrg_level_name()); orgLevelInfo.put("tricode", ""); orgLevelInfo.put("org_level_uuid", user.getOrg_level_uuid()); orgLevelInfo.put("children", menus); JSONArray array = new JSONArray(); array.add(orgLevelInfo); return array; } // data = baseDao.listTable(CmnConst.product_oa_DIRECTORY, " directory_type = 2 AND created_by = ?", new Object[]{userId}, "tricode"); } baseDao.listInternationDataTable(data, null); JSONArray menus = this.encapsulationTree(data); //获取当前公司 JSONObject orgLevelInfo = new JSONObject(); orgLevelInfo.put("directory_name", user.getOrg_level_name()); orgLevelInfo.put("tricode", ""); orgLevelInfo.put("org_level_uuid", user.getOrg_level_uuid()); orgLevelInfo.put("children",menus); JSONArray array = new JSONArray(); array.add(orgLevelInfo); return array; } /** * 封装树方法 * @param * @return * @throws BaseException */ @Override public JSONArray encapsulationTree(DataTableEntity data) throws BaseException { JSONArray menus = new JSONArray(); JSONObject parent_menu = new JSONObject(); if (!BaseUtil.dataTableIsEmpty(data)) { for (int i = 0; i < data.getRows(); i++) { FieldSetEntity fs = data.getFieldSetEntity(i); JSONObject menu = BaseUtil.fieldSetEntityToJson(fs); String tricode = fs.getString(CmnConst.TRICODE_PARENT); if (StringUtils.isEmpty(tricode) || parent_menu.getString(tricode) == null) { menus.add(menu); } else {// 上级目录 JSONObject pm = parent_menu.getJSONObject(tricode); JSONArray subs = pm.getJSONArray(CmnConst.CHILDREN); JSONArray submenus = null; if (subs == null) { submenus = new JSONArray(); pm.put(CmnConst.CHILDREN, submenus); } else { submenus = subs; } submenus.add(menu); } parent_menu.put(menu.getString(CmnConst.TRICODE), menu); } } return menus; } /** * 封装树方法 * * @param * @return * @throws BaseException */ @Override public JSONArray encapsulationTree(DataTableEntity data) throws BaseException { JSONArray menus = new JSONArray(); JSONObject parent_menu = new JSONObject(); if (!BaseUtil.dataTableIsEmpty(data)) { for (int i = 0; i < data.getRows(); i++) { FieldSetEntity fs = data.getFieldSetEntity(i); JSONObject menu = BaseUtil.fieldSetEntityToJson(fs); String tricode = fs.getString(CmnConst.TRICODE_PARENT); if (StringUtils.isEmpty(tricode) || parent_menu.getString(tricode) == null) { menus.add(menu); } else {// 上级目录 JSONObject pm = parent_menu.getJSONObject(tricode); JSONArray subs = pm.getJSONArray(CmnConst.CHILDREN); JSONArray submenus = null; if (subs == null) { submenus = new JSONArray(); pm.put(CmnConst.CHILDREN, submenus); } else { submenus = subs; } submenus.add(menu); } parent_menu.put(menu.getString(CmnConst.TRICODE), menu); } } return menus; } @Override public FieldSetEntity documentDirectoryInfo(FieldSetEntity fieldSetEntity) throws BaseException { String uuid = fieldSetEntity.getString(CmnConst.UUID); return baseDao.getFieldSetEntity(CmnConst.product_oa_DIRECTORY, uuid, true); } @Override public FieldSetEntity documentDirectoryInfo(FieldSetEntity fieldSetEntity) throws BaseException { String uuid = fieldSetEntity.getString(CmnConst.UUID); return baseDao.getFieldSetEntity(CmnConst.PRODUCT_OA_DIRECTORY, uuid, true); } /** * 移动到目录列表(根据当前用户过滤展示目录列表) * 获取用户有新增(上传)权限的列表 * @param * @return * @throws BaseException */ @Override public DataTableEntity moveToList(FieldSetEntity fse) throws BaseException { String type = fse.getString(CmnConst.DIRECTORY_TYPE); StringBuffer sql = new StringBuffer(); Integer userId = SpringMVCContextHolder.getCurrentUser().getUser_id(); StringBuffer param = new StringBuffer(); //1为单位文件夹 if("1".equals(type)) { param.append("%").append(userId).append("%"); sql.append("SELECT a.* FROM "+CmnConst.product_oa_DIRECTORY+" a LEFT JOIN ") .append(" product_oa_directory_rights b ON a.uuid = b.directory_uuid ") .append(" LEFT JOIN product_sys_organizational_structure_storage c on b.storage_uuid = c.uuid ") .append(" WHERE a.directory_type = 1 AND b.rigths like '%3%' AND c.staff_ids like ? GROUP BY a.tricode "); }else { param.append(userId); sql.append("SELECT * FROM product_oa_directory ") .append(" WHERE directory_type = 2 AND created_by = ? "); } DataTableEntity dataTableEntity = baseDao.listTable(sql.toString(), new String[]{param.toString()}); baseDao.listInternationDataTable(dataTableEntity, null); return dataTableEntity; } /** * 移动到目录列表(根据当前用户过滤展示目录列表) 获取用户有新增(上传)权限的列表 * * @param * @return * @throws BaseException */ @Override public DataTableEntity moveToList(FieldSetEntity fse) throws BaseException { String type = fse.getString(CmnConst.DIRECTORY_TYPE); StringBuffer sql = new StringBuffer(); Integer userId = SpringMVCContextHolder.getCurrentUser().getUser_id(); StringBuffer param = new StringBuffer(); // 1为单位文件夹 if ("1".equals(type)) { param.append("%").append(userId).append("%"); sql.append("SELECT a.* FROM " + CmnConst.PRODUCT_OA_DIRECTORY + " a LEFT JOIN ") .append(" PRODUCT_OA_directory_rights b ON a.uuid = b.directory_uuid ") .append(" LEFT JOIN product_sys_organizational_structure_storage c on b.storage_uuid = c.uuid ") .append(" WHERE a.directory_type = 1 AND b.rigths like '%3%' AND c.staff_ids like ? GROUP BY a.tricode "); } else { param.append(userId); sql.append("SELECT * FROM PRODUCT_OA_directory ").append(" WHERE directory_type = 2 AND created_by = ? "); } DataTableEntity dataTableEntity = baseDao.listTable(sql.toString(), new String[] { param.toString() }); baseDao.listInternationDataTable(dataTableEntity, null); return dataTableEntity; } @Override @Transactional public boolean upDocumentDirectoryName(FieldSetEntity fse) throws BaseException { String uuid = fse.getString(CmnConst.UUID); String directoryName = fse.getString(CmnConst.DIRECTORY_NAME); FieldSetEntity docField = baseDao.getFieldSetEntity(CmnConst.product_oa_DIRECTORY, uuid, false); docField.setValue(CmnConst.DIRECTORY_NAME, directoryName); return baseDao.update(docField); } @Override @Transactional public boolean upDocumentDirectoryName(FieldSetEntity fse) throws BaseException { String uuid = fse.getString(CmnConst.UUID); String directoryName = fse.getString(CmnConst.DIRECTORY_NAME); FieldSetEntity docField = baseDao.getFieldSetEntity(CmnConst.PRODUCT_OA_DIRECTORY, uuid, false); docField.setValue(CmnConst.DIRECTORY_NAME, directoryName); return baseDao.update(docField); } } src/main/java/com/product/file/service/DocumentService.java
@@ -63,7 +63,7 @@ List<String> fileNameList = ListUtils.newArrayList(); for (int i = 0, length = attachments.getRows(); i < length; i++) { FieldSetEntity fieldSet = new FieldSetEntity(); fieldSet.setTableName(CmnConst.product_oa_DOCUMENT); fieldSet.setTableName(CmnConst.PRODUCT_OA_DOCUMENT); FieldSetEntity fse = attachments.getFieldSetEntity(i); //文件目录uuid fieldSet.setValue(CmnConst.DIRECTORY_UUID, directory_uuid); @@ -94,7 +94,7 @@ String file_name = fieldSetEntity.getString(CmnConst.FILE_NAME); fieldSetEntity.setValue(CmnConst.UPDATED_BY, SpringMVCContextHolder.getCurrentUser().getUser_id());// 修改人 fieldSetEntity.setValue(CmnConst.UPDATED_UTC_DATETIME, DateUtils.getDateTime());// 修改时间 FieldSetEntity fie = baseDao.getFieldSetEntity(CmnConst.product_oa_DOCUMENT, uuid, false); FieldSetEntity fie = baseDao.getFieldSetEntity(CmnConst.PRODUCT_OA_DOCUMENT, uuid, false); String name = fie.getString(CmnConst.FILE_NAME); //每次修改都亲空已读人员 fieldSetEntity.setValue(CmnConst.READ_NUM, ""); @@ -117,7 +117,7 @@ String file_names = fieldSetEntity.getString(CmnConst.FILE_NAME); String[] file_name = file_names.split(","); String[] uuid = uuids.split(","); boolean flag = baseDao.delete(CmnConst.product_oa_DOCUMENT, uuid); boolean flag = baseDao.delete(CmnConst.PRODUCT_OA_DOCUMENT, uuid); this.documentation(uuid, "删除", file_name, null); return flag; } @@ -135,7 +135,7 @@ .append(" a.*,CONCAT(CONVERT(a.file_size / 1024, decimal(10,2)), 'KB') file_size_kb,b.show_name name") // .append(" concat(c.attachment_domain,'/',c.attachment_container,'/',c.module_uuid,'/',c.attachment_title,?) path ") .append(" FROM ") .append(" (SELECT * FROM product_oa_document WHERE directory_uuid = ? ") .append(" (SELECT * FROM PRODUCT_OA_document WHERE directory_uuid = ? ") .append(queryFilter) .append(" ) a LEFT JOIN product_sys_staffs b ON a.created_by = b.user_id ") .append(" LEFT JOIN product_sys_attachments c ON b.staff_avatar=c.uuid "); @@ -148,7 +148,7 @@ @Override public FieldSetEntity documentInfo(FieldSetEntity fieldSetEntity) throws BaseException { String uuid = fieldSetEntity.getString(CmnConst.UUID); FieldSetEntity fieldSet = baseDao.getFieldSetEntity(CmnConst.product_oa_DOCUMENT, uuid, true); FieldSetEntity fieldSet = baseDao.getFieldSetEntity(CmnConst.PRODUCT_OA_DOCUMENT, uuid, true); String file_name = fieldSet.getString(CmnConst.FILE_NAME); String user_ids = fieldSetEntity.getString(CmnConst.USER_IDS); String read = fieldSetEntity.getString(CmnConst.READ_NUM); @@ -166,11 +166,11 @@ SystemUser user = SpringMVCContextHolder.getCurrentUser(); DataTableEntity dataTableEntity = new DataTableEntity(); FieldMetaEntity fieldMeta = new FieldMetaEntity(); fieldMeta.setTableName(new String[]{CmnConst.product_oa_DOCUMENT_LOG}); fieldMeta.setTableName(new String[]{CmnConst.PRODUCT_OA_DOCUMENT_LOG}); dataTableEntity.setMeta(fieldMeta); for (int i = 0; i < uuid.length; i++) { FieldSetEntity fieldSetEntity = new FieldSetEntity(); fieldSetEntity.setTableName(CmnConst.product_oa_DOCUMENT_LOG); fieldSetEntity.setTableName(CmnConst.PRODUCT_OA_DOCUMENT_LOG); fieldSetEntity.setMeta(fieldMeta); fieldSetEntity.setValue(CmnConst.DOCUMENT_UUID, uuid[i]); //fieldSetEntity.setValue(CmnConst.RECORD,record); @@ -198,11 +198,11 @@ SystemUser user = SpringMVCContextHolder.getCurrentUser(); DataTableEntity dataTableEntity = new DataTableEntity(); FieldMetaEntity fieldMeta = new FieldMetaEntity(); fieldMeta.setTableName(new String[]{CmnConst.product_oa_DOCUMENT_LOG}); fieldMeta.setTableName(new String[]{CmnConst.PRODUCT_OA_DOCUMENT_LOG}); dataTableEntity.setMeta(fieldMeta); for (int i = 0; i < uuid.length; i++) { FieldSetEntity fieldSetEntity = new FieldSetEntity(); fieldSetEntity.setTableName(CmnConst.product_oa_DOCUMENT_LOG); fieldSetEntity.setTableName(CmnConst.PRODUCT_OA_DOCUMENT_LOG); fieldSetEntity.setMeta(fieldMeta); fieldSetEntity.setValue(CmnConst.DOCUMENT_UUID, uuid[i]); //fieldSetEntity.setValue(CmnConst.RECORD,record); @@ -280,7 +280,7 @@ String butt = ""; DataTableEntity dataTable = null; FieldSetEntity fse = new FieldSetEntity(); fse.setTableName(CmnConst.product_oa_DOCUMENT); fse.setTableName(CmnConst.PRODUCT_OA_DOCUMENT); if ("1".equals(fieldSetEntity.getString(CmnConst.DIRECTORY_TYPE))) { //获取的user_id Integer user_id = SpringMVCContextHolder.getCurrentUser().getUser_id(); @@ -288,10 +288,10 @@ String directory_uuid = fieldSetEntity.getString(CmnConst.DIRECTORY_UUID); //String key = "%,140,%"; DataTableEntity dataTableEntity = new DataTableEntity(); FieldSetEntity org = baseDao.getFieldSetByFilter(CmnConst.product_oa_DIRECTORY_RIGHTS, "directory_uuid=?", new String[]{directory_uuid}, false); FieldSetEntity org = baseDao.getFieldSetByFilter(CmnConst.PRODUCT_OA_DIRECTORY_RIGHTS, "directory_uuid=?", new String[]{directory_uuid}, false); if (verifyOrgExist(org.getString("storage_uuid"))) { StringBuffer sql = new StringBuffer(); sql.append(" SELECT substring_index(substring_index(a.rigths,',',b.help_topic_id+1),',',-1) fun FROM product_oa_directory_rights a ") sql.append(" SELECT substring_index(substring_index(a.rigths,',',b.help_topic_id+1),',',-1) fun FROM PRODUCT_OA_directory_rights a ") .append(" INNER join mysql.help_topic b on b.help_topic_id < (length(a.rigths) - length(replace(a.rigths,',',''))+1) ") .append(" WHERE a.directory_uuid = ? "); dataTableEntity = baseDao.listTable(sql.toString(), new String[]{directory_uuid}); @@ -346,8 +346,8 @@ //1为公司文件目录 if ("1".equals(type)) { //String staffId = user.getCurrentStaff().getString("staff_id"); sql.append(" select a.* from product_oa_directory a ") .append(" LEFT JOIN ( SELECT a.directory_uuid FROM product_oa_directory_rights a LEFT JOIN product_sys_organizational_structure_storage b ") sql.append(" select a.* from PRODUCT_OA_directory a ") .append(" LEFT JOIN ( SELECT a.directory_uuid FROM PRODUCT_OA_directory_rights a LEFT JOIN product_sys_organizational_structure_storage b ") .append(" on a.storage_uuid = b.uuid WHERE a.rigths like '%3%' AND CONCAT(',',b.staff_ids,',') like ? GROUP BY ") .append(" a.directory_uuid) b ON a.uuid = b.directory_uuid where a.directory_type = 1 and a.org_level_uuid = ? "); String staffId = "%" + user.getCurrentStaff().getString("staff_id") + "%"; @@ -355,7 +355,7 @@ param.add(user.getOrg_level_uuid()); //param.add("%,140,%"); } else { sql.append(" select * from product_oa_directory where directory_type = 2 AND created_by = ? "); sql.append(" select * from PRODUCT_OA_directory where directory_type = 2 AND created_by = ? "); param.add(user.getUser_id()); } JSONObject object = new JSONObject(); @@ -369,12 +369,12 @@ sql.append(" and tricode_parent = ? "); //加载文件路径 DataTableEntity dataTableEntity = documentDirectoryService.getDirectoryStructure(fse); object.put("product_oa_directory_path", BaseUtil.dataTableEntityToJson(dataTableEntity)); object.put("PRODUCT_OA_directory_path", BaseUtil.dataTableEntityToJson(dataTableEntity)); } //sql.append(" GROUP BY tricode,tricode_parent,directory_name"); DataTableEntity data = baseDao.listTable(sql.toString(), param.toArray()); object.put("product_oa_directory_sub", BaseUtil.dataTableEntityToJson(data)); object.put("PRODUCT_OA_directory_sub", BaseUtil.dataTableEntityToJson(data)); baseDao.listInternationDataTable(data, null); return object; @@ -384,7 +384,7 @@ @Transactional public void downloadFile(FieldSetEntity fieldSetEntity) throws BaseException { String uuid = fieldSetEntity.getString(CmnConst.UUID); FieldSetEntity fieldSet = baseDao.getFieldSetEntity(CmnConst.product_oa_DOCUMENT, uuid, false); FieldSetEntity fieldSet = baseDao.getFieldSetEntity(CmnConst.PRODUCT_OA_DOCUMENT, uuid, false); String file_name = fieldSet.getString(CmnConst.FILE_NAME); this.documentation(new String[]{uuid}, "下载", new String[]{file_name}, null); this.markRead(fieldSet); @@ -429,7 +429,7 @@ //1为公司文件夹 if (directory_type == 1) { StringBuffer sql = new StringBuffer(); sql.append(" SELECT * FROM product_oa_directory_rights ") sql.append(" SELECT * FROM PRODUCT_OA_directory_rights ") .append(" WHERE directory_uuid = ? ") .append(" AND rigths like '%3%' AND concat(',',storage_uuid,',') like ? ");//3为新增 String user_id = String.valueOf(SpringMVCContextHolder.getCurrentUser().getUser_id()); @@ -439,12 +439,12 @@ } //1为个人文件夹 if (directory_type == 2 || row > 0) { FieldSetEntity fieldSetEntity = baseDao.getFieldSetEntity(CmnConst.product_oa_DIRECTORY, directory_uuid, false); FieldSetEntity fieldSetEntity = baseDao.getFieldSetEntity(CmnConst.PRODUCT_OA_DIRECTORY, directory_uuid, false); //获取移动到的目录名 String directory_name = fieldSetEntity.getString(CmnConst.DIRECTORY_NAME); String uuids = fse.getString(CmnConst.UUID); String[] uuid = uuids.split(","); DataTableEntity dataTable = baseDao.listTable(CmnConst.product_oa_DOCUMENT, BaseUtil.buildQuestionMarkFilter(CmnConst.UUID, uuid.length, true), uuid); DataTableEntity dataTable = baseDao.listTable(CmnConst.PRODUCT_OA_DOCUMENT, BaseUtil.buildQuestionMarkFilter(CmnConst.UUID, uuid.length, true), uuid); List<String> uuidList = ListUtils.newArrayList(); List<String> fileNameList = ListUtils.newArrayList(); for (int i = 0, length = dataTable.getRows(); i < length; i++) { @@ -454,7 +454,7 @@ String params = directory_uuid + "," + uuids; String[] param = params.split(","); boolean flag = baseDao.executeUpdate("UPDATE product_oa_document SET directory_uuid = ? WHERE " + BaseUtil.buildQuestionMarkFilter(CmnConst.UUID, uuid.length, true), param); boolean flag = baseDao.executeUpdate("UPDATE PRODUCT_OA_document SET directory_uuid = ? WHERE " + BaseUtil.buildQuestionMarkFilter(CmnConst.UUID, uuid.length, true), param); this.documentation(uuidList.toArray(), "移动", fileNameList.toArray(), directory_name); return flag; } else { @@ -464,7 +464,7 @@ @Override public DataTableEntity getDocumentLog(FieldSetEntity fieldSetEntity) throws BaseException { return baseDao.listTable("SELECT CONCAT(b.show_name, a.state) log,a.created_utc_datetime FROM product_oa_document_log a LEFT JOIN product_sys_staffs b on a.created_by = b.user_id WHERE document_uuid = ? ORDER BY a.created_utc_datetime DESC", return baseDao.listTable("SELECT CONCAT(b.show_name, a.state) log,a.created_utc_datetime FROM PRODUCT_OA_document_log a LEFT JOIN product_sys_staffs b on a.created_by = b.user_id WHERE document_uuid = ? ORDER BY a.created_utc_datetime DESC", new String[]{fieldSetEntity.getString(CmnConst.DOCUMENT_UUID)}, fieldSetEntity.getInteger(CmnConst.PAGESIZE), fieldSetEntity.getInteger(CmnConst.CPAGE)); } }