Search in sources :

Example 36 with ServiceMethodAuthority

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

the class EmployeeLogicServiceImpl method getTreeData.

@ServiceMethodAuthority(type = { ServiceMethodType.SELECT })
@Override
public List<Map<String, Object>> getTreeData(String basePath) throws ServiceException, Exception {
    List<Map<String, Object>> items = new LinkedList<Map<String, Object>>();
    List<EmployeeVO> empList = this.getEmployeeService().findForJoinHier();
    if (empList == null || empList.size() < 1) {
        return items;
    }
    for (EmployeeVO emp : empList) {
        // 先放沒有父親的員工資料
        if (!(super.isBlank(emp.getSupOid()) || BscConstants.EMPLOYEE_HIER_ZERO_OID.equals(emp.getSupOid()))) {
            continue;
        }
        Map<String, Object> parentDataMap = new LinkedHashMap<String, Object>();
        parentDataMap.put("type", "parent");
        parentDataMap.put("id", emp.getOid());
        parentDataMap.put("name", IconUtils.getMenuIcon(basePath, TREE_ICON_ID) + StringEscapeUtils.escapeHtml4(this.getTreeShowName(emp)));
        parentDataMap.put("oid", emp.getOid());
        items.add(parentDataMap);
    }
    // 再開始放孩子
    for (int ix = 0; ix < items.size(); ix++) {
        Map<String, Object> parentDataMap = items.get(ix);
        String oid = (String) parentDataMap.get("oid");
        this.getTreeData(basePath, parentDataMap, empList, oid);
    }
    return items;
}
Also used : EmployeeVO(com.netsteadfast.greenstep.vo.EmployeeVO) Map(java.util.Map) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) LinkedList(java.util.LinkedList) LinkedHashMap(java.util.LinkedHashMap) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority)

Example 37 with ServiceMethodAuthority

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

the class EmployeeLogicServiceImpl method updateSupervisor.

@ServiceMethodAuthority(type = { ServiceMethodType.UPDATE })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<Boolean> updateSupervisor(EmployeeVO employee, String supervisorOid) throws ServiceException, Exception {
    if (employee == null || super.isBlank(employee.getOid()) || super.isBlank(supervisorOid)) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
    }
    DefaultResult<Boolean> result = new DefaultResult<Boolean>();
    result.setValue(Boolean.FALSE);
    result.setSystemMessage(new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.UPDATE_FAIL)));
    employee = this.findEmployeeData(employee.getOid());
    this.deleteHierarchy(employee);
    if ("root".equals(supervisorOid) || "r".equals(supervisorOid)) {
        this.createHierarchy(employee, BscConstants.EMPLOYEE_HIER_ZERO_OID);
    } else {
        EmployeeVO newHierEmployee = this.findEmployeeData(supervisorOid);
        // 找當前員工的的資料, 不因該存在要update的新關聯主管
        if (this.foundChild(employee.getOid(), newHierEmployee.getOid())) {
            throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.DATA_ERRORS));
        }
        this.createHierarchy(employee, newHierEmployee.getOid());
    }
    result.setValue(Boolean.TRUE);
    result.setSystemMessage(new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.UPDATE_SUCCESS)));
    return result;
}
Also used : SystemMessage(com.netsteadfast.greenstep.base.model.SystemMessage) EmployeeVO(com.netsteadfast.greenstep.vo.EmployeeVO) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) DefaultResult(com.netsteadfast.greenstep.base.model.DefaultResult) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority) Transactional(org.springframework.transaction.annotation.Transactional)

Example 38 with ServiceMethodAuthority

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

the class EmployeeLogicServiceImpl method delete.

@ServiceMethodAuthority(type = { ServiceMethodType.DELETE })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<Boolean> delete(EmployeeVO employee) throws ServiceException, Exception {
    if (employee == null || super.isBlank(employee.getOid())) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
    }
    employee = this.findEmployeeData(employee.getOid());
    AccountVO account = this.findAccountData(employee.getAccount());
    if (this.isAdministrator(account.getAccount())) {
        throw new ServiceException("Administrator cannot delete!");
    }
    // check account data for other table use.
    this.checkInformationRelated(account, employee);
    this.deleteEmployeeOrganization(employee);
    // delete user role
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("account", account.getAccount());
    List<TbUserRole> userRoles = this.getUserRoleService().findListByParams(params);
    for (int i = 0; userRoles != null && i < userRoles.size(); i++) {
        TbUserRole uRole = userRoles.get(i);
        this.getUserRoleService().delete(uRole);
    }
    // delete BB_REPORT_ROLE_VIEW
    params.clear();
    params.put("idName", account.getAccount());
    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 EMP_ID = :empId
    this.measureDataService.deleteForEmpId(employee.getEmpId());
    this.monitorItemScoreService.deleteForEmpId(employee.getEmpId());
    this.deleteHierarchy(employee);
    this.getAccountService().deleteByPKng(account.getOid());
    return getEmployeeService().deleteObject(employee);
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) BbReportRoleView(com.netsteadfast.greenstep.po.hbm.BbReportRoleView) TbUserRole(com.netsteadfast.greenstep.po.hbm.TbUserRole) AccountVO(com.netsteadfast.greenstep.vo.AccountVO) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority) Transactional(org.springframework.transaction.annotation.Transactional)

Example 39 with ServiceMethodAuthority

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

the class AggregationMethodLogicServiceImpl method delete.

@ServiceMethodAuthority(type = { ServiceMethodType.DELETE })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<Boolean> delete(AggregationMethodVO aggregationMethod) throws ServiceException, Exception {
    if (null == aggregationMethod || super.isBlank(aggregationMethod.getOid())) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
    }
    AggregationMethodVO oldAggregationMethod = AggregationMethodUtils.findSimpleByOid(aggregationMethod.getOid());
    Map<String, Object> paramMap = new HashMap<String, Object>();
    paramMap.put("cal", oldAggregationMethod.getAggrId());
    if (this.kpiService.countByParams(paramMap) > 0) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.DATA_CANNOT_DELETE));
    }
    return this.aggregationMethodService.deleteObject(aggregationMethod);
}
Also used : AggregationMethodVO(com.netsteadfast.greenstep.vo.AggregationMethodVO) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) HashMap(java.util.HashMap) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority) Transactional(org.springframework.transaction.annotation.Transactional)

Example 40 with ServiceMethodAuthority

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

the class DegreeFeedbackLogicServiceImpl method confirmTask.

@ServiceMethodAuthority(type = { ServiceMethodType.SELECT, ServiceMethodType.UPDATE })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public void confirmTask(String projectOid, String taskId, String reason, String confirm) throws ServiceException, Exception {
    if (super.isBlank(projectOid) || super.isBlank(taskId) || super.isBlank(confirm)) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
    }
    DegreeFeedbackProjectVO project = new DegreeFeedbackProjectVO();
    project.setOid(projectOid);
    DefaultResult<DegreeFeedbackProjectVO> result = this.degreeFeedbackProjectService.findObjectByOid(project);
    if (result.getValue() == null) {
        throw new ServiceException(result.getSystemMessage().toString());
    }
    project = result.getValue();
    this.completeTask(taskId, this.getProcessFlowParam(projectOid, confirm, reason));
    List<BusinessProcessManagementTaskVO> tasks = this.queryTaskByVariableProjectOid(projectOid);
    if (null != tasks && tasks.size() > 0) {
        return;
    }
    // 流程跑完了, 更新專案flag , 讓專案發佈
    if (YesNo.YES.equals(confirm)) {
        project.setPublishFlag(YesNo.YES);
        this.degreeFeedbackProjectService.updateObject(project);
    }
}
Also used : BusinessProcessManagementTaskVO(com.netsteadfast.greenstep.vo.BusinessProcessManagementTaskVO) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) DegreeFeedbackProjectVO(com.netsteadfast.greenstep.vo.DegreeFeedbackProjectVO) 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