Search in sources :

Example 6 with MeasureDataVO

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

the class MeasureDataCalendarUtils method findMeasureData.

/**
	 * 這個 method 主要給 Expression 使用, 避免近入LogicService 處理時影響到 Transaction
	 * 
	 * @param kpiId
	 * @param date
	 * @param frequency
	 * @param orgaId
	 * @param emplId
	 * @return
	 * @throws ServiceException
	 * @throws Exception
	 */
@SuppressWarnings("rawtypes")
public static MeasureDataVO findMeasureData(String kpiId, String date, String frequency, String orgaId, String emplId) throws ServiceException, Exception {
    transactionTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
    transactionTemplate.setIsolationLevel(TransactionDefinition.ISOLATION_DEFAULT);
    transactionTemplate.setReadOnly(true);
    MeasureDataVO measureData = null;
    try {
        measureData = (MeasureDataVO) transactionTemplate.execute(new TransactionCallback() {

            @Override
            public Object doInTransaction(TransactionStatus status) {
                MeasureDataVO value = new MeasureDataVO();
                value.setKpiId(kpiId);
                value.setDate(date);
                value.setFrequency(frequency);
                value.setOrgId(orgaId);
                value.setEmpId(emplId);
                try {
                    DefaultResult<MeasureDataVO> mdResult = measureDataService.findByUK(value);
                    if (mdResult.getValue() != null) {
                        value = mdResult.getValue();
                    } else {
                        value = null;
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                    value = null;
                }
                return value;
            }
        });
    } catch (Exception e) {
        throw e;
    }
    return measureData;
}
Also used : TransactionCallback(org.springframework.transaction.support.TransactionCallback) TransactionStatus(org.springframework.transaction.TransactionStatus) MeasureDataVO(com.netsteadfast.greenstep.vo.MeasureDataVO) DefaultResult(com.netsteadfast.greenstep.base.model.DefaultResult) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException)

Aggregations

MeasureDataVO (com.netsteadfast.greenstep.vo.MeasureDataVO)6 ServiceException (com.netsteadfast.greenstep.base.exception.ServiceException)3 DefaultResult (com.netsteadfast.greenstep.base.model.DefaultResult)3 ServiceMethodAuthority (com.netsteadfast.greenstep.base.model.ServiceMethodAuthority)2 SystemMessage (com.netsteadfast.greenstep.base.model.SystemMessage)2 KpiVO (com.netsteadfast.greenstep.vo.KpiVO)2 Transactional (org.springframework.transaction.annotation.Transactional)2 BscStructTreeObj (com.netsteadfast.greenstep.bsc.model.BscStructTreeObj)1 BbMeasureData (com.netsteadfast.greenstep.po.hbm.BbMeasureData)1 ObjectiveVO (com.netsteadfast.greenstep.vo.ObjectiveVO)1 PerspectiveVO (com.netsteadfast.greenstep.vo.PerspectiveVO)1 VisionVO (com.netsteadfast.greenstep.vo.VisionVO)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 TransactionStatus (org.springframework.transaction.TransactionStatus)1 TransactionCallback (org.springframework.transaction.support.TransactionCallback)1