Search in sources :

Example 81 with ServiceMethodAuthority

use of com.netsteadfast.greenstep.base.model.ServiceMethodAuthority in project bamboobsc by billchen198318.

the class EmployeeLogicServiceImpl method createOrgChartData.

/**
	 * 這個 Method 的 ServiceMethodAuthority 權限給查詢狀態
	 * 這裡的 basePath 只是要取 getTreeData 時參數要用, 再這是沒有用處的
	 */
@ServiceMethodAuthority(type = { ServiceMethodType.SELECT })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<String> createOrgChartData(String basePath, EmployeeVO currentEmployee) throws ServiceException, Exception {
    if (null != currentEmployee && !super.isBlank(currentEmployee.getOid())) {
        currentEmployee = this.findEmployeeData(currentEmployee.getOid());
    }
    List<Map<String, Object>> treeMap = this.getTreeData(basePath);
    if (null == treeMap || treeMap.size() < 1) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.SEARCH_NO_DATA));
    }
    this.resetTreeMapContentForOrgChartData(treeMap, currentEmployee);
    Map<String, Object> rootMap = new HashMap<String, Object>();
    rootMap.put("name", "Employee hierarchy");
    rootMap.put("title", "hierarchy structure");
    rootMap.put("children", treeMap);
    ObjectMapper objectMapper = new ObjectMapper();
    String jsonData = objectMapper.writeValueAsString(rootMap);
    String uploadOid = UploadSupportUtils.create(Constants.getSystem(), UploadTypes.IS_TEMP, false, jsonData.getBytes(), SimpleUtils.getUUIDStr() + ".json");
    DefaultResult<String> result = new DefaultResult<String>();
    result.setValue(uploadOid);
    result.setSystemMessage(new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.INSERT_SUCCESS)));
    return result;
}
Also used : SystemMessage(com.netsteadfast.greenstep.base.model.SystemMessage) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) DefaultResult(com.netsteadfast.greenstep.base.model.DefaultResult) Map(java.util.Map) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority) Transactional(org.springframework.transaction.annotation.Transactional)

Example 82 with ServiceMethodAuthority

use of com.netsteadfast.greenstep.base.model.ServiceMethodAuthority in project bamboobsc by billchen198318.

the class EmployeeLogicServiceImpl method getOrgChartData.

/**
	 * 這個 Method 的 ServiceMethodAuthority 權限給查詢狀態
	 * 這裡的 basePath 只是要取 getTreeData 時參數要用, 再這是沒有用處的
	 */
@ServiceMethodAuthority(type = { ServiceMethodType.SELECT })
@Override
public DefaultResult<Map<String, Object>> getOrgChartData(String basePath, EmployeeVO currentEmployee) throws ServiceException, Exception {
    if (null != currentEmployee && !super.isBlank(currentEmployee.getOid())) {
        currentEmployee = this.findEmployeeData(currentEmployee.getOid());
    }
    List<Map<String, Object>> treeMap = this.getTreeData(basePath);
    if (null == treeMap || treeMap.size() < 1) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.SEARCH_NO_DATA));
    }
    this.resetTreeMapContentForOrgChartData(treeMap, currentEmployee);
    Map<String, Object> rootMap = new HashMap<String, Object>();
    rootMap.put("name", "Employee hierarchy");
    rootMap.put("title", "hierarchy structure");
    rootMap.put("children", treeMap);
    DefaultResult<Map<String, Object>> result = new DefaultResult<Map<String, Object>>();
    result.setValue(rootMap);
    result.setSystemMessage(new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.INSERT_SUCCESS)));
    return result;
}
Also used : SystemMessage(com.netsteadfast.greenstep.base.model.SystemMessage) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) DefaultResult(com.netsteadfast.greenstep.base.model.DefaultResult) Map(java.util.Map) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority)

Example 83 with ServiceMethodAuthority

use of com.netsteadfast.greenstep.base.model.ServiceMethodAuthority in project bamboobsc by billchen198318.

the class EmployeeLogicServiceImpl method create.

@ServiceMethodAuthority(type = { ServiceMethodType.INSERT })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<EmployeeVO> create(EmployeeVO employee, List<String> organizationOid) throws ServiceException, Exception {
    if (employee == null || super.isBlank(employee.getEmpId())) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
    }
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("empId", employee.getEmpId());
    if (this.getEmployeeService().countByParams(params) > 0) {
        throw new ServiceException("Please change another Id!");
    }
    AccountVO account = this.tranAccount(employee);
    if (this.isAdministrator(account.getAccount())) {
        throw new ServiceException("Please change another Account!");
    }
    DefaultResult<AccountVO> mResult = this.getAccountService().saveObject(account);
    if (mResult.getValue() == null) {
        throw new ServiceException(mResult.getSystemMessage().getValue());
    }
    DefaultResult<EmployeeVO> result = this.getEmployeeService().saveObject(employee);
    employee = result.getValue();
    this.createEmployeeOrganization(employee, organizationOid);
    // create default role
    UserRoleVO userRole = new UserRoleVO();
    userRole.setAccount(employee.getAccount());
    userRole.setRole(this.roleLogicService.getDefaultUserRole());
    userRole.setDescription(employee.getAccount() + " `s role!");
    this.getUserRoleService().saveObject(userRole);
    this.createHierarchy(employee, BscConstants.EMPLOYEE_HIER_ZERO_OID);
    return result;
}
Also used : EmployeeVO(com.netsteadfast.greenstep.vo.EmployeeVO) UserRoleVO(com.netsteadfast.greenstep.vo.UserRoleVO) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) AccountVO(com.netsteadfast.greenstep.vo.AccountVO) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority) Transactional(org.springframework.transaction.annotation.Transactional)

Example 84 with ServiceMethodAuthority

use of com.netsteadfast.greenstep.base.model.ServiceMethodAuthority in project bamboobsc by billchen198318.

the class OrganizationLogicServiceImpl method createOrgChartData.

/**
	 * 這個 Method 的 ServiceMethodAuthority 權限給查詢狀態
	 * 這裡的 basePath 只是要取 getTreeData 時參數要用, 再這是沒有用處的
	 */
@ServiceMethodAuthority(type = { ServiceMethodType.SELECT })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<String> createOrgChartData(String basePath, OrganizationVO currentOrganization) throws ServiceException, Exception {
    if (null != currentOrganization && !super.isBlank(currentOrganization.getOid())) {
        currentOrganization = this.findOrganizationData(currentOrganization.getOid());
    }
    List<Map<String, Object>> treeMap = this.getTreeData(basePath, false, "");
    if (null == treeMap || treeMap.size() < 1) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.SEARCH_NO_DATA));
    }
    this.resetTreeMapContentForOrgChartData(treeMap, currentOrganization);
    Map<String, Object> rootMap = new HashMap<String, Object>();
    rootMap.put("name", "Organization / Department hierarchy");
    rootMap.put("title", "hierarchy structure");
    rootMap.put("children", treeMap);
    ObjectMapper objectMapper = new ObjectMapper();
    String jsonData = objectMapper.writeValueAsString(rootMap);
    String uploadOid = UploadSupportUtils.create(Constants.getSystem(), UploadTypes.IS_TEMP, false, jsonData.getBytes(), SimpleUtils.getUUIDStr() + ".json");
    DefaultResult<String> result = new DefaultResult<String>();
    result.setValue(uploadOid);
    result.setSystemMessage(new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.INSERT_SUCCESS)));
    return result;
}
Also used : SystemMessage(com.netsteadfast.greenstep.base.model.SystemMessage) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) DefaultResult(com.netsteadfast.greenstep.base.model.DefaultResult) Map(java.util.Map) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority) Transactional(org.springframework.transaction.annotation.Transactional)

Example 85 with ServiceMethodAuthority

use of com.netsteadfast.greenstep.base.model.ServiceMethodAuthority in project bamboobsc by billchen198318.

the class OrganizationLogicServiceImpl method delete.

@ServiceMethodAuthority(type = { ServiceMethodType.DELETE })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<Boolean> delete(OrganizationVO organization) throws ServiceException, Exception {
    if (organization == null || super.isBlank(organization.getOid())) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
    }
    organization = this.findOrganizationData(organization.getOid());
    if (this.foundChild(organization)) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.DATA_CANNOT_DELETE));
    }
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("orgId", organization.getOrgId());
    if (this.employeeOrgaService.countByParams(params) > 0) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.DATA_CANNOT_DELETE));
    }
    if (this.kpiOrgaService.countByParams(params) > 0) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.DATA_CANNOT_DELETE));
    }
    if (this.pdcaOrgaService.countByParams(params) > 0) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.DATA_CANNOT_DELETE));
    }
    if (this.pdcaMeasureFreqService.countByParams(params) > 0) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.DATA_CANNOT_DELETE));
    }
    if (this.tsaMeasureFreqService.countByParams(params) > 0) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.DATA_CANNOT_DELETE));
    }
    this.deleteParent(organization);
    this.swotService.deleteForOrgId(organization.getOrgId());
    // delete BB_REPORT_ROLE_VIEW
    params.clear();
    params.put("idName", organization.getOrgId());
    List<BbReportRoleView> reportRoleViews = this.reportRoleViewService.findListByParams(params);
    for (int i = 0; reportRoleViews != null && i < reportRoleViews.size(); i++) {
        BbReportRoleView reportRoleView = reportRoleViews.get(i);
        this.reportRoleViewService.delete(reportRoleView);
    }
    // delete from BB_MEASURE_DATA where ORG_ID = :orgId
    this.measureDataService.deleteForOrgId(organization.getOrgId());
    this.monitorItemScoreService.deleteForOrgId(organization.getOrgId());
    return this.getOrganizationService().deleteObject(organization);
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) BbReportRoleView(com.netsteadfast.greenstep.po.hbm.BbReportRoleView) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

ServiceMethodAuthority (com.netsteadfast.greenstep.base.model.ServiceMethodAuthority)95 ServiceException (com.netsteadfast.greenstep.base.exception.ServiceException)91 Transactional (org.springframework.transaction.annotation.Transactional)84 HashMap (java.util.HashMap)32 SystemMessage (com.netsteadfast.greenstep.base.model.SystemMessage)31 DefaultResult (com.netsteadfast.greenstep.base.model.DefaultResult)29 SysVO (com.netsteadfast.greenstep.vo.SysVO)13 LinkedHashMap (java.util.LinkedHashMap)13 Map (java.util.Map)12 AccountVO (com.netsteadfast.greenstep.vo.AccountVO)7 VisionVO (com.netsteadfast.greenstep.vo.VisionVO)7 BaseEntity (com.netsteadfast.greenstep.base.model.BaseEntity)6 EmployeeVO (com.netsteadfast.greenstep.vo.EmployeeVO)6 PerspectiveVO (com.netsteadfast.greenstep.vo.PerspectiveVO)6 IOException (java.io.IOException)6 BaseValueObj (com.netsteadfast.greenstep.base.model.BaseValueObj)5 RoleVO (com.netsteadfast.greenstep.vo.RoleVO)5 SysProgVO (com.netsteadfast.greenstep.vo.SysProgVO)5 UserRoleVO (com.netsteadfast.greenstep.vo.UserRoleVO)5 BbReportRoleView (com.netsteadfast.greenstep.po.hbm.BbReportRoleView)4