Search in sources :

Example 6 with AggregationMethodVO

use of com.netsteadfast.greenstep.vo.AggregationMethodVO 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 7 with AggregationMethodVO

use of com.netsteadfast.greenstep.vo.AggregationMethodVO in project bamboobsc by billchen198318.

the class AggregationMethodServiceImpl method findSimpleByOid.

@Override
public DefaultResult<AggregationMethodVO> findSimpleByOid(String aggrOid) throws ServiceException, Exception {
    if (StringUtils.isBlank(aggrOid) || super.isNoSelectId(aggrOid)) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
    }
    AggregationMethodVO aggr = this.aggregationMethodDAO.findSimpleByOid(aggrOid);
    DefaultResult<AggregationMethodVO> result = new DefaultResult<AggregationMethodVO>();
    if (aggr != null && !StringUtils.isBlank(aggr.getOid())) {
        result.setValue(aggr);
    } else {
        result.setSystemMessage(new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.SEARCH_NO_DATA)));
    }
    return result;
}
Also used : SystemMessage(com.netsteadfast.greenstep.base.model.SystemMessage) AggregationMethodVO(com.netsteadfast.greenstep.vo.AggregationMethodVO) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) DefaultResult(com.netsteadfast.greenstep.base.model.DefaultResult)

Example 8 with AggregationMethodVO

use of com.netsteadfast.greenstep.vo.AggregationMethodVO in project bamboobsc by billchen198318.

the class AggregationMethodServiceImpl method findForSimple.

@Override
public DefaultResult<List<AggregationMethodVO>> findForSimple() throws ServiceException, Exception {
    DefaultResult<List<AggregationMethodVO>> result = new DefaultResult<List<AggregationMethodVO>>();
    List<AggregationMethodVO> searchList = this.aggregationMethodDAO.findForSimple();
    if (searchList != null && searchList.size() > 0) {
        result.setValue(searchList);
    } else {
        result.setSystemMessage(new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.SEARCH_NO_DATA)));
    }
    return result;
}
Also used : SystemMessage(com.netsteadfast.greenstep.base.model.SystemMessage) AggregationMethodVO(com.netsteadfast.greenstep.vo.AggregationMethodVO) List(java.util.List) DefaultResult(com.netsteadfast.greenstep.base.model.DefaultResult)

Example 9 with AggregationMethodVO

use of com.netsteadfast.greenstep.vo.AggregationMethodVO in project bamboobsc by billchen198318.

the class AggregationMethodLogicServiceImpl method update.

@ServiceMethodAuthority(type = { ServiceMethodType.UPDATE })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<AggregationMethodVO> update(AggregationMethodVO aggregationMethod) throws ServiceException, Exception {
    if (null == aggregationMethod || super.isBlank(aggregationMethod.getName()) || super.isBlank(aggregationMethod.getOid())) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
    }
    AggregationMethodVO oldAggregationMethod = AggregationMethodUtils.findSimpleByOid(aggregationMethod.getOid());
    // ID 是 UK 不能改
    aggregationMethod.setAggrId(oldAggregationMethod.getAggrId());
    long countName1 = 0;
    long countName2 = 0;
    Map<String, Object> paramMap = new HashMap<String, Object>();
    paramMap.put("name", aggregationMethod.getName());
    countName1 = this.aggregationMethodService.countByParams(paramMap);
    paramMap.put("aggrId", aggregationMethod.getAggrId());
    countName2 = this.aggregationMethodService.countByParams(paramMap);
    if (countName1 > 0 && countName2 == 0) {
        // 有別筆資料名稱是一樣的
        throw new ServiceException("Please change another name!");
    }
    this.setStringValueMaxLength(aggregationMethod, "description", MAX_DESCRIPTION_LENGTH);
    return this.aggregationMethodService.updateObject(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 10 with AggregationMethodVO

use of com.netsteadfast.greenstep.vo.AggregationMethodVO in project bamboobsc by billchen198318.

the class AggregationMethodUtils method findAggregationMethodByUK.

private static AggregationMethodVO findAggregationMethodByUK(String id) throws ServiceException, Exception {
    Map<String, AggregationMethodVO> datas = aggrMethodUkThreadLocal.get();
    if (datas != null) {
        if (datas.get(id) != null) {
            return datas.get(id);
        }
    }
    AggregationMethodVO aggr = new AggregationMethodVO();
    aggr.setAggrId(id);
    DefaultResult<AggregationMethodVO> result = aggregationMethodService.findByUK(aggr);
    if (result.getValue() == null) {
        throw new ServiceException(result.getSystemMessage().getValue());
    }
    aggr = result.getValue();
    aggrMethodUkThreadLocal.get().put(id, aggr);
    return aggr;
}
Also used : AggregationMethodVO(com.netsteadfast.greenstep.vo.AggregationMethodVO) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException)

Aggregations

AggregationMethodVO (com.netsteadfast.greenstep.vo.AggregationMethodVO)12 ServiceException (com.netsteadfast.greenstep.base.exception.ServiceException)6 DefaultResult (com.netsteadfast.greenstep.base.model.DefaultResult)3 SystemMessage (com.netsteadfast.greenstep.base.model.SystemMessage)3 ServiceMethodAuthority (com.netsteadfast.greenstep.base.model.ServiceMethodAuthority)2 HashMap (java.util.HashMap)2 Transactional (org.springframework.transaction.annotation.Transactional)2 BscMixDataVO (com.netsteadfast.greenstep.bsc.vo.BscMixDataVO)1 FormulaVO (com.netsteadfast.greenstep.vo.FormulaVO)1 KpiVO (com.netsteadfast.greenstep.vo.KpiVO)1 ObjectiveVO (com.netsteadfast.greenstep.vo.ObjectiveVO)1 PerspectiveVO (com.netsteadfast.greenstep.vo.PerspectiveVO)1 VisionVO (com.netsteadfast.greenstep.vo.VisionVO)1 List (java.util.List)1