use of com.netsteadfast.greenstep.base.exception.ServiceException in project bamboobsc by billchen198318.
the class EmployeeLogicServiceImpl method update.
@ServiceMethodAuthority(type = { ServiceMethodType.UPDATE })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<EmployeeVO> update(EmployeeVO employee, List<String> organizationOid) throws ServiceException, Exception {
if (employee == null || super.isBlank(employee.getOid())) {
throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
}
EmployeeVO dbEmployee = this.findEmployeeData(employee.getOid());
this.deleteEmployeeOrganization(dbEmployee);
employee.setAccount(dbEmployee.getAccount());
employee.setEmpId(dbEmployee.getEmpId());
DefaultResult<EmployeeVO> result = this.getEmployeeService().updateObject(employee);
if (result.getValue() == null) {
throw new ServiceException(result.getSystemMessage().getValue());
}
this.createEmployeeOrganization(result.getValue(), organizationOid);
return result;
}
use of com.netsteadfast.greenstep.base.exception.ServiceException 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;
}
use of com.netsteadfast.greenstep.base.exception.ServiceException 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);
}
use of com.netsteadfast.greenstep.base.exception.ServiceException in project bamboobsc by billchen198318.
the class PdcaLogicServiceImpl method createDocuments.
private void createDocuments(PdcaVO pdca, List<String> attachment) throws ServiceException, Exception {
if (attachment == null || attachment.size() < 1) {
return;
}
for (String oid : attachment) {
SysUploadVO upload = this.findUploadDataForNoByteContent(oid);
if (!(upload.getSystem().equals(Constants.getSystem()) && upload.getType().equals(UploadTypes.IS_TEMP))) {
throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.DATA_ERRORS));
}
PdcaDocVO pdcaDoc = new PdcaDocVO();
pdcaDoc.setPdcaOid(pdca.getOid());
pdcaDoc.setUploadOid(upload.getOid());
pdcaDoc.setViewMode(UploadSupportUtils.getViewMode(upload.getShowName()));
DefaultResult<PdcaDocVO> result = this.pdcaDocService.saveObject(pdcaDoc);
if (result.getValue() == null) {
throw new ServiceException(result.getSystemMessage().getValue());
}
UploadSupportUtils.updateType(oid, UploadTypes.IS_PDCA_DOCUMENT);
}
}
use of com.netsteadfast.greenstep.base.exception.ServiceException in project bamboobsc by billchen198318.
the class PdcaLogicServiceImpl method findPdca.
private PdcaVO findPdca(String oid) throws ServiceException, Exception {
PdcaVO pdca = new PdcaVO();
pdca.setOid(oid);
DefaultResult<PdcaVO> result = this.pdcaService.findObjectByOid(pdca);
if (result.getValue() == null) {
throw new ServiceException(result.getSystemMessage().getValue());
}
pdca = result.getValue();
return pdca;
}
Aggregations