use of com.netsteadfast.greenstep.vo.PerspectiveVO in project bamboobsc by billchen198318.
the class PersonalAndOrganizationReportDateRangeScoreCommand method execute.
@SuppressWarnings("unchecked")
@Override
public boolean execute(Context context) throws Exception {
if (this.getResult(context) == null || !(this.getResult(context) instanceof BscStructTreeObj)) {
return false;
}
float total = 0.0f;
BscStructTreeObj treeObj = (BscStructTreeObj) this.getResult(context);
String year = StringUtils.defaultString((String) context.get("startYearDate")).trim();
String dateType = StringUtils.defaultString((String) context.get("dateType")).trim();
for (VisionVO vision : treeObj.getVisions()) {
for (PerspectiveVO perspective : vision.getPerspectives()) {
for (ObjectiveVO objective : perspective.getObjectives()) {
for (KpiVO kpi : objective.getKpis()) {
this.setDateRangeScore(kpi, dateType, year);
// 只有一筆資料
total = total + kpi.getDateRangeScores().get(0).getScore();
}
}
}
}
context.put("total", total);
return false;
}
use of com.netsteadfast.greenstep.vo.PerspectiveVO in project bamboobsc by billchen198318.
the class ImportDataLogicServiceImpl method importPerspectivesCsv.
@ServiceMethodAuthority(type = { ServiceMethodType.INSERT, ServiceMethodType.UPDATE })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<Boolean> importPerspectivesCsv(String uploadOid) throws ServiceException, Exception {
List<Map<String, String>> csvResults = UploadSupportUtils.getTransformSegmentData(uploadOid, "TRAN002");
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 perId = data.get("PER_ID");
String visId = data.get("VIS_ID");
String name = data.get("NAME");
String weight = data.get("WEIGHT");
String target = data.get("TARGET");
String min = data.get("MIN");
String description = data.get("DESCRIPTION");
if (super.isBlank(perId)) {
msg.append("row: " + row + " perspective-id is blank." + Constants.HTML_BR);
continue;
}
if (super.isBlank(visId)) {
msg.append("row: " + row + " vision-id is blank." + Constants.HTML_BR);
continue;
}
if (super.isBlank(name)) {
msg.append("row: " + row + " name is blank." + Constants.HTML_BR);
continue;
}
if (super.isBlank(weight)) {
msg.append("row: " + row + " weight is blank." + Constants.HTML_BR);
continue;
}
if (super.isBlank(target)) {
msg.append("row: " + row + " target is blank." + Constants.HTML_BR);
continue;
}
if (super.isBlank(min)) {
msg.append("row: " + row + " min is blank." + Constants.HTML_BR);
continue;
}
if (!NumberUtils.isNumber(weight)) {
msg.append("row: " + row + " weight is not number." + Constants.HTML_BR);
continue;
}
if (!NumberUtils.isNumber(target)) {
msg.append("row: " + row + " target is not number." + Constants.HTML_BR);
continue;
}
if (!NumberUtils.isNumber(min)) {
msg.append("row: " + row + " min is not number." + Constants.HTML_BR);
continue;
}
paramMap.clear();
paramMap.put("visId", visId);
if (this.visionService.countByParams(paramMap) < 1) {
throw new ServiceException("row: " + row + " vision is not found " + visId);
}
DefaultResult<VisionVO> visionResult = this.visionService.findForSimpleByVisId(visId);
if (visionResult.getValue() == null) {
throw new ServiceException(visionResult.getSystemMessage().getValue());
}
PerspectiveVO perspective = new PerspectiveVO();
perspective.setPerId(perId);
perspective.setVisId(visId);
perspective.setName(name);
perspective.setWeight(new BigDecimal(weight));
perspective.setTarget(Float.valueOf(target));
perspective.setMin(Float.valueOf(min));
perspective.setDescription(description);
paramMap.clear();
paramMap.put("perId", perId);
if (this.perspectiveService.countByParams(paramMap) > 0) {
// update
DefaultResult<PerspectiveVO> oldResult = this.perspectiveService.findByUK(perspective);
perspective.setOid(oldResult.getValue().getOid());
this.perspectiveLogicService.update(perspective, visionResult.getValue().getOid());
} else {
// insert
this.perspectiveLogicService.create(perspective, visionResult.getValue().getOid());
}
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.vo.PerspectiveVO in project bamboobsc by billchen198318.
the class ImportDataLogicServiceImpl method importObjectivesCsv.
@ServiceMethodAuthority(type = { ServiceMethodType.INSERT, ServiceMethodType.UPDATE })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<Boolean> importObjectivesCsv(String uploadOid) throws ServiceException, Exception {
List<Map<String, String>> csvResults = UploadSupportUtils.getTransformSegmentData(uploadOid, "TRAN003");
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();
for (int i = 0; i < csvResults.size(); i++) {
int row = i + 1;
Map<String, String> data = csvResults.get(i);
String objId = data.get("OBJ_ID");
String perId = data.get("PER_ID");
String name = data.get("NAME");
String weight = data.get("WEIGHT");
String target = data.get("TARGET");
String min = data.get("MIN");
String description = data.get("DESCRIPTION");
if (super.isBlank(objId)) {
msg.append("row: " + row + " objective-id is blank." + Constants.HTML_BR);
continue;
}
if (super.isBlank(perId)) {
msg.append("row: " + row + " perspective-id is blank." + Constants.HTML_BR);
continue;
}
if (super.isBlank(name)) {
msg.append("row: " + row + " name is blank." + Constants.HTML_BR);
continue;
}
if (super.isBlank(weight)) {
msg.append("row: " + row + " weight is blank." + Constants.HTML_BR);
continue;
}
if (super.isBlank(target)) {
msg.append("row: " + row + " target is blank." + Constants.HTML_BR);
continue;
}
if (super.isBlank(min)) {
msg.append("row: " + row + " min is blank." + Constants.HTML_BR);
continue;
}
if (!NumberUtils.isNumber(weight)) {
msg.append("row: " + row + " weight is not number." + Constants.HTML_BR);
continue;
}
if (!NumberUtils.isNumber(target)) {
msg.append("row: " + row + " target is not number." + Constants.HTML_BR);
continue;
}
if (!NumberUtils.isNumber(min)) {
msg.append("row: " + row + " min is not number." + Constants.HTML_BR);
continue;
}
PerspectiveVO perspective = new PerspectiveVO();
perspective.setPerId(perId);
DefaultResult<PerspectiveVO> perResult = this.perspectiveService.findByUK(perspective);
if (perResult.getValue() == null) {
throw new ServiceException("row: " + row + " perspective is not found " + perId);
}
perspective = perResult.getValue();
ObjectiveVO objective = new ObjectiveVO();
objective.setObjId(objId);
DefaultResult<ObjectiveVO> oldResult = this.objectiveService.findByUK(objective);
objective.setObjId(objId);
objective.setPerId(perId);
objective.setName(name);
objective.setWeight(new BigDecimal(weight));
objective.setTarget(Float.valueOf(target));
objective.setMin(Float.valueOf(min));
objective.setDescription(description);
if (oldResult.getValue() != null) {
// update
objective.setOid(oldResult.getValue().getOid());
this.objectiveLogicService.update(objective, perspective.getOid());
} else {
// insert
this.objectiveLogicService.create(objective, perspective.getOid());
}
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.vo.PerspectiveVO in project bamboobsc by billchen198318.
the class HistoryItemScoreReportContentQueryUtils method fill2ValueObjectList.
public static List<MonitorItemScoreVO> fill2ValueObjectList(List<BbMonitorItemScore> monitorItemScores) throws ServiceException, Exception {
List<MonitorItemScoreVO> results = new ArrayList<MonitorItemScoreVO>();
if (null == monitorItemScores) {
return results;
}
List<VisionVO> basicDataList = getBasicDataList();
for (BbMonitorItemScore monitorScoreSrc : monitorItemScores) {
MonitorItemScoreVO monitorScoreDest = new MonitorItemScoreVO();
monitorItemScoreService.doMapper(monitorScoreSrc, monitorScoreDest, IMonitorItemScoreService.MAPPER_ID_PO2VO);
String id = monitorScoreSrc.getItemId();
String name = "";
String itemType = monitorScoreSrc.getItemType();
if (MonitorItemType.VISION.equals(itemType)) {
DefaultResult<VisionVO> visionResult = visionService.findForSimpleByVisId(id);
if (visionResult.getValue() == null) {
throw new ServiceException(visionResult.getSystemMessage().getValue());
}
VisionVO vision = visionResult.getValue();
name = getItemNameWithVisionGroup(MonitorItemType.VISION, vision.getVisId(), vision.getTitle(), basicDataList);
}
if (MonitorItemType.PERSPECTIVES.equals(itemType)) {
PerspectiveVO perspective = new PerspectiveVO();
perspective.setPerId(id);
DefaultResult<PerspectiveVO> perspectiveResult = perspectiveService.findByUK(perspective);
if (perspectiveResult.getValue() == null) {
throw new ServiceException(perspectiveResult.getSystemMessage().getValue());
}
perspective = perspectiveResult.getValue();
name = getItemNameWithVisionGroup(MonitorItemType.PERSPECTIVES, perspective.getPerId(), perspective.getName(), basicDataList);
}
if (MonitorItemType.STRATEGY_OF_OBJECTIVES.equals(itemType)) {
ObjectiveVO objective = new ObjectiveVO();
objective.setObjId(id);
DefaultResult<ObjectiveVO> objectiveResult = objectiveService.findByUK(objective);
if (objectiveResult.getValue() == null) {
throw new ServiceException(objectiveResult.getSystemMessage().getValue());
}
objective = objectiveResult.getValue();
name = getItemNameWithVisionGroup(MonitorItemType.STRATEGY_OF_OBJECTIVES, objective.getObjId(), objective.getName(), basicDataList);
}
if (MonitorItemType.KPI.equals(itemType)) {
KpiVO kpi = new KpiVO();
kpi.setId(id);
DefaultResult<KpiVO> kpiResult = kpiService.findByUK(kpi);
if (kpiResult.getValue() == null) {
throw new ServiceException(kpiResult.getSystemMessage().getValue());
}
kpi = kpiResult.getValue();
name = getItemNameWithVisionGroup(MonitorItemType.KPI, kpi.getId(), kpi.getName(), basicDataList);
}
monitorScoreDest.setName(name);
monitorScoreDest.setOrganizationName(monitorScoreSrc.getOrgId());
monitorScoreDest.setEmployeeName(monitorScoreSrc.getEmpId());
if (!BscConstants.MEASURE_DATA_ORGANIZATION_FULL.equals(monitorScoreSrc.getOrgId())) {
OrganizationVO organization = BscBaseLogicServiceCommonSupport.findOrganizationDataByUK(organizationService, monitorScoreSrc.getOrgId());
monitorScoreDest.setOrganizationName(monitorScoreSrc.getOrgId() + " - " + organization.getName());
}
if (!BscConstants.MEASURE_DATA_EMPLOYEE_FULL.equals(monitorScoreSrc.getEmpId())) {
EmployeeVO employee = BscBaseLogicServiceCommonSupport.findEmployeeDataByEmpId(employeeService, monitorScoreSrc.getEmpId());
monitorScoreDest.setEmployeeName(monitorScoreSrc.getEmpId() + " - " + employee.getFullName());
}
results.add(monitorScoreDest);
}
return results;
}
use of com.netsteadfast.greenstep.vo.PerspectiveVO in project bamboobsc by billchen198318.
the class HistoryItemScoreReportContentQueryUtils method getLineChartData.
public static List<Map<String, Object>> getLineChartData(String itemType, String frequency, String dateVal, String orgId, String empId) throws ServiceException, Exception {
List<Map<String, Object>> dataList = new ArrayList<Map<String, Object>>();
Map<String, List<MonitorItemScoreVO>> itemScoreDataMap = monitorItemScoreService.getHistoryDataList(itemType, frequency, dateVal, orgId, empId);
if (itemScoreDataMap == null || itemScoreDataMap.size() < 1) {
return dataList;
}
List<VisionVO> basicDataList = getBasicDataList();
for (Map.Entry<String, List<MonitorItemScoreVO>> entry : itemScoreDataMap.entrySet()) {
String name = "";
String id = entry.getKey();
List<MonitorItemScoreVO> scoreList = entry.getValue();
if (scoreList == null || scoreList.size() < 1) {
continue;
}
if (MonitorItemType.VISION.equals(itemType)) {
DefaultResult<VisionVO> visionResult = visionService.findForSimpleByVisId(id);
if (visionResult.getValue() == null) {
throw new ServiceException(visionResult.getSystemMessage().getValue());
}
VisionVO vision = visionResult.getValue();
name = getItemNameWithVisionGroup(MonitorItemType.VISION, vision.getVisId(), vision.getTitle(), basicDataList);
}
if (MonitorItemType.PERSPECTIVES.equals(itemType)) {
PerspectiveVO perspective = new PerspectiveVO();
perspective.setPerId(id);
DefaultResult<PerspectiveVO> perspectiveResult = perspectiveService.findByUK(perspective);
if (perspectiveResult.getValue() == null) {
throw new ServiceException(perspectiveResult.getSystemMessage().getValue());
}
perspective = perspectiveResult.getValue();
name = getItemNameWithVisionGroup(MonitorItemType.PERSPECTIVES, perspective.getPerId(), perspective.getName(), basicDataList);
}
if (MonitorItemType.STRATEGY_OF_OBJECTIVES.equals(itemType)) {
ObjectiveVO objective = new ObjectiveVO();
objective.setObjId(id);
DefaultResult<ObjectiveVO> objectiveResult = objectiveService.findByUK(objective);
if (objectiveResult.getValue() == null) {
throw new ServiceException(objectiveResult.getSystemMessage().getValue());
}
objective = objectiveResult.getValue();
name = getItemNameWithVisionGroup(MonitorItemType.STRATEGY_OF_OBJECTIVES, objective.getObjId(), objective.getName(), basicDataList);
}
if (MonitorItemType.KPI.equals(itemType)) {
KpiVO kpi = new KpiVO();
kpi.setId(id);
DefaultResult<KpiVO> kpiResult = kpiService.findByUK(kpi);
if (kpiResult.getValue() == null) {
throw new ServiceException(kpiResult.getSystemMessage().getValue());
}
kpi = kpiResult.getValue();
name = getItemNameWithVisionGroup(MonitorItemType.KPI, kpi.getId(), kpi.getName(), basicDataList);
}
if (StringUtils.isBlank(name)) {
throw new ServiceException("Name not found!");
}
Map<String, Object> chartDataMap = new HashMap<String, Object>();
chartDataMap.put("name", name);
chartDataMap.put("data", new LinkedList<Float>());
for (MonitorItemScoreVO itemScore : scoreList) {
((List<Float>) chartDataMap.get("data")).add(Float.valueOf(itemScore.getScore()));
}
dataList.add(chartDataMap);
}
return dataList;
}
Aggregations