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;
}
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;
}
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;
}
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;
}
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);
}
Aggregations