use of com.netsteadfast.greenstep.base.model.ServiceMethodAuthority in project bamboobsc by billchen198318.
the class OrganizationLogicServiceImpl method update.
@ServiceMethodAuthority(type = { ServiceMethodType.UPDATE })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<OrganizationVO> update(OrganizationVO organization) throws ServiceException, Exception {
if (organization == null || super.isBlank(organization.getOid())) {
throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
}
this.checkOrganizationIdIsZero(organization);
OrganizationVO dbOrganization = this.findOrganizationData(organization.getOid());
organization.setOrgId(dbOrganization.getOrgId());
this.setStringValueMaxLength(organization, "description", MAX_DESCRIPTION_LENGTH);
this.handlerLongitudeAndLatitude(organization);
return this.getOrganizationService().updateObject(organization);
}
use of com.netsteadfast.greenstep.base.model.ServiceMethodAuthority in project bamboobsc by billchen198318.
the class OrganizationLogicServiceImpl method getOrgChartData.
/**
* 這個 Method 的 ServiceMethodAuthority 權限給查詢狀態
* 這裡的 basePath 只是要取 getTreeData 時參數要用, 再這是沒有用處的
*/
@ServiceMethodAuthority(type = { ServiceMethodType.SELECT })
@Override
public DefaultResult<Map<String, Object>> getOrgChartData(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);
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 OrganizationLogicServiceImpl method getTreeData.
/**
* 為了組織架構 tree 的呈現用, json 資料
*
* 不包含
* {
* "identifier":"id",
* "label":"name",
*
* ==================================================
* 只包含 items 的資料內容
* ==================================================
*
* "items":[
* ...............
* ]
* ==================================================
*
* }
*
* @param basePath
* @param checkBox 是否打開checkBox
* @param appendId 已被打勾的部門OID組成的字串, 如 1b2ac208-345c-4f93-92c5-4b26aead31d2;3ba52439-6756-45e8-8269-ae7b4fb6a3dc
* @return
* @throws ServiceException
* @throws Exception
*/
@ServiceMethodAuthority(type = { ServiceMethodType.SELECT })
@Override
public List<Map<String, Object>> getTreeData(String basePath, boolean checkBox, String appendId) throws ServiceException, Exception {
List<Map<String, Object>> items = new LinkedList<Map<String, Object>>();
List<OrganizationVO> orgList = this.getOrganizationService().findForJoinParent();
if (orgList == null || orgList.size() < 1) {
return items;
}
for (OrganizationVO org : orgList) {
// 先放沒有父親的ORG-ID
if (!(super.isBlank(org.getParId()) || BscConstants.ORGANIZATION_ZERO_ID.equals(org.getParId()))) {
continue;
}
Map<String, Object> parentDataMap = new LinkedHashMap<String, Object>();
parentDataMap.put("type", "parent");
parentDataMap.put("name", (checkBox ? getCheckBoxHtmlContent(org, appendId) : "") + IconUtils.getMenuIcon(basePath, TREE_ICON_ID) + StringEscapeUtils.escapeHtml4(org.getName()));
parentDataMap.put("id", org.getOid());
parentDataMap.put("orgId", org.getOrgId());
items.add(parentDataMap);
}
// 再開始放孩子
for (int ix = 0; ix < items.size(); ix++) {
Map<String, Object> parentDataMap = items.get(ix);
String orgId = (String) parentDataMap.get("orgId");
this.getTreeData(basePath, checkBox, appendId, parentDataMap, orgList, orgId);
}
return items;
}
use of com.netsteadfast.greenstep.base.model.ServiceMethodAuthority in project bamboobsc by billchen198318.
the class ImportDataLogicServiceImpl method importMeasureData.
@ServiceMethodAuthority(type = { ServiceMethodType.INSERT, ServiceMethodType.UPDATE })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<Boolean> importMeasureData(String uploadOid) throws ServiceException, Exception {
List<Map<String, String>> csvResults = UploadSupportUtils.getTransformSegmentData(uploadOid, "TRAN005");
if (csvResults.size() < 1) {
throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.DATA_NO_EXIST));
}
boolean success = false;
DefaultResult<Boolean> result = new DefaultResult<Boolean>();
StringBuilder msg = new StringBuilder();
Map<String, Object> paramMap = new HashMap<String, Object>();
for (int i = 0; i < csvResults.size(); i++) {
int row = i + 1;
Map<String, String> data = csvResults.get(i);
String kpiId = data.get("KPI_ID");
String date = data.get("DATE");
String target = data.get("TARGET");
String actual = data.get("ACTUAL");
String frequency = data.get("FREQUENCY");
String orgId = data.get("ORG_ID");
String empId = data.get("EMP_ID");
if (super.isBlank(kpiId)) {
msg.append("row: " + row + " kpi id is blank." + Constants.HTML_BR);
continue;
}
if (super.isBlank(date)) {
msg.append("row: " + row + " date is blank." + Constants.HTML_BR);
continue;
}
if (super.isBlank(target)) {
msg.append("row: " + row + " target is blank." + Constants.HTML_BR);
continue;
}
if (super.isBlank(actual)) {
msg.append("row: " + row + " actual is blank." + Constants.HTML_BR);
continue;
}
if (super.isBlank(frequency)) {
msg.append("row: " + row + " frequency is blank." + Constants.HTML_BR);
continue;
}
if (super.isBlank(orgId)) {
msg.append("row: " + row + " organization-id is blank." + Constants.HTML_BR);
continue;
}
if (super.isBlank(empId)) {
msg.append("row: " + row + " employee-no is blank." + Constants.HTML_BR);
continue;
}
if (!SimpleUtils.isDate(date)) {
msg.append("row: " + row + " is not date " + date + Constants.HTML_BR);
continue;
}
if (!NumberUtils.isNumber(target)) {
msg.append("row: " + row + " target is not number." + Constants.HTML_BR);
continue;
}
if (!NumberUtils.isNumber(actual)) {
msg.append("row: " + row + " actual is not number." + Constants.HTML_BR);
continue;
}
if (BscMeasureDataFrequency.getFrequencyMap(false).get(frequency) == null) {
msg.append("row: " + row + " frequency is not found." + Constants.HTML_BR);
continue;
}
paramMap.clear();
paramMap.put("id", kpiId);
if (this.kpiService.countByParams(paramMap) < 1) {
msg.append("row: " + row + " KPI is not found " + kpiId + Constants.HTML_BR);
continue;
}
if (!BscConstants.MEASURE_DATA_ORGANIZATION_FULL.equals(orgId)) {
paramMap.clear();
paramMap.put("orgId", orgId);
if (this.organizationService.countByParams(paramMap) < 1) {
msg.append("row: " + row + " organization-id is not found " + orgId + Constants.HTML_BR);
continue;
}
}
if (!BscConstants.MEASURE_DATA_EMPLOYEE_FULL.equals(empId)) {
paramMap.clear();
paramMap.put("empId", empId);
if (this.employeeService.countByParams(paramMap) < 1) {
msg.append("row: " + row + " employee-no is not found " + empId + Constants.HTML_BR);
continue;
}
}
MeasureDataVO measureData = new MeasureDataVO();
measureData.setKpiId(kpiId);
measureData.setDate(date);
measureData.setTarget(Float.valueOf(target));
measureData.setActual(Float.valueOf(actual));
measureData.setFrequency(frequency);
measureData.setOrgId(orgId);
measureData.setEmpId(empId);
DefaultResult<MeasureDataVO> oldResult = this.measureDataService.findByUK(measureData);
if (oldResult.getValue() != null) {
// update
measureData.setOid(oldResult.getValue().getOid());
this.measureDataService.updateObject(measureData);
} else {
// insert
this.measureDataService.saveObject(measureData);
}
success = true;
}
if (msg.length() > 0) {
result.setSystemMessage(new SystemMessage(msg.toString()));
} else {
result.setSystemMessage(new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.UPDATE_SUCCESS)));
}
result.setValue(success);
return result;
}
use of com.netsteadfast.greenstep.base.model.ServiceMethodAuthority in project bamboobsc by billchen198318.
the class PerspectiveLogicServiceImpl method update.
@ServiceMethodAuthority(type = { ServiceMethodType.UPDATE })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<PerspectiveVO> update(PerspectiveVO perspective, String visionOid) throws ServiceException, Exception {
if (null == perspective || super.isBlank(perspective.getOid()) || super.isBlank(visionOid)) {
throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
}
DefaultResult<PerspectiveVO> oldResult = this.perspectiveService.findObjectByOid(perspective);
if (oldResult.getValue() == null) {
throw new ServiceException(oldResult.getSystemMessage().getValue());
}
DefaultResult<VisionVO> vResult = this.visionService.findForSimple(visionOid);
if (vResult.getValue() == null) {
throw new ServiceException(vResult.getSystemMessage().getValue());
}
VisionVO vision = vResult.getValue();
perspective.setVisId(vision.getVisId());
perspective.setPerId(oldResult.getValue().getPerId());
this.setStringValueMaxLength(perspective, "description", MAX_DESCRIPTION_LENGTH);
return this.perspectiveService.updateObject(perspective);
}
Aggregations