|  | @ -5,12 +5,14 @@ import com.yihu.jw.restmodel.common.CommonContants;
 | 
	
		
			
				|  |  | import com.yihu.jw.restmodel.exception.ApiException;
 | 
	
		
			
				|  |  | import com.yihu.jw.restmodel.wlyy.WlyyContants;
 | 
	
		
			
				|  |  | import com.yihu.jw.wlyy.Agreement.dao.WlyyAgreementKpiDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.wlyy.Agreement.entity.WlyyAgreement;
 | 
	
		
			
				|  |  | import com.yihu.jw.wlyy.Agreement.entity.WlyyAgreementKpi;
 | 
	
		
			
				|  |  | import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  | import org.springframework.stereotype.Service;
 | 
	
		
			
				|  |  | import org.springframework.util.StringUtils;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import javax.persistence.Transient;
 | 
	
		
			
				|  |  | import java.util.Date;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | /**
 | 
	
		
			
				|  |  |  * Created by Administrator on 2017/6/1 0001.
 | 
	
	
		
			
				|  | @ -21,11 +23,23 @@ public class WlyyAgreementKpiService extends BaseJpaService<WlyyAgreementKpi, Wl
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private WlyyAgreementKpiDao wlyyAgreementKpiDao;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private WlyyAgreementService wlyyAgreementService;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @Transient
 | 
	
		
			
				|  |  |     public WlyyAgreementKpi create(WlyyAgreementKpi wlyyAgreementKpi) {
 | 
	
		
			
				|  |  |         if (StringUtils.isEmpty(wlyyAgreementKpi.getCode())) {
 | 
	
		
			
				|  |  |             throw new ApiException(WlyyContants.AgreementKpi.message_fail_code_is_null, CommonContants.common_error_params_code);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         //判断agreement是否存在
 | 
	
		
			
				|  |  |         String agreementCode = wlyyAgreementKpi.getAgreementCode();
 | 
	
		
			
				|  |  |         if (StringUtils.isEmpty(agreementCode)) {
 | 
	
		
			
				|  |  |             throw new ApiException(WlyyContants.AgreementKpi.message_fail_agreementCode_is_null, CommonContants.common_error_params_code);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         WlyyAgreement agreement = wlyyAgreementService.findByCode(agreementCode);
 | 
	
		
			
				|  |  |         if(agreement == null){
 | 
	
		
			
				|  |  |             throw new ApiException(WlyyContants.AgreementKpi.message_fail_agreement_is_null, CommonContants.common_error_params_code);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (StringUtils.isEmpty(wlyyAgreementKpi.getKpiName())) {
 | 
	
		
			
				|  |  |             throw new ApiException(WlyyContants.AgreementKpi.message_fail_kpiName_is_null, CommonContants.common_error_params_code);
 | 
	
		
			
				|  |  |         }
 | 
	
	
		
			
				|  | @ -35,6 +49,10 @@ public class WlyyAgreementKpiService extends BaseJpaService<WlyyAgreementKpi, Wl
 | 
	
		
			
				|  |  |         if (StringUtils.isEmpty(wlyyAgreementKpi.getStatus())) {
 | 
	
		
			
				|  |  |             throw new ApiException(WlyyContants.AgreementKpi.message_fail_status_is_null, CommonContants.common_error_params_code);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         //设置创建时间和修改时间
 | 
	
		
			
				|  |  |         Date date = new Date();
 | 
	
		
			
				|  |  |         wlyyAgreementKpi.setCreateTime(date);
 | 
	
		
			
				|  |  |         wlyyAgreementKpi.setUpdaateTime(date);
 | 
	
		
			
				|  |  |         return wlyyAgreementKpiDao.save(wlyyAgreementKpi);
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -44,6 +62,15 @@ public class WlyyAgreementKpiService extends BaseJpaService<WlyyAgreementKpi, Wl
 | 
	
		
			
				|  |  |         if (StringUtils.isEmpty(code)) {
 | 
	
		
			
				|  |  |             throw new ApiException(WlyyContants.AgreementKpi.message_fail_code_is_null, CommonContants.common_error_params_code);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         //判断agreement是否存在
 | 
	
		
			
				|  |  |         String agreementCode = wlyyAgreementKpi.getAgreementCode();
 | 
	
		
			
				|  |  |         if (StringUtils.isEmpty(agreementCode)) {
 | 
	
		
			
				|  |  |             throw new ApiException(WlyyContants.AgreementKpi.message_fail_agreementCode_is_null, CommonContants.common_error_params_code);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         WlyyAgreement agreement = wlyyAgreementService.findByCode(agreementCode);
 | 
	
		
			
				|  |  |         if(agreement == null){
 | 
	
		
			
				|  |  |             throw new ApiException(WlyyContants.AgreementKpi.message_fail_agreement_is_null, CommonContants.common_error_params_code);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (StringUtils.isEmpty(wlyyAgreementKpi.getKpiName())) {
 | 
	
		
			
				|  |  |             throw new ApiException(WlyyContants.AgreementKpi.message_fail_kpiName_is_null, CommonContants.common_error_params_code);
 | 
	
		
			
				|  |  |         }
 | 
	
	
		
			
				|  | @ -61,6 +88,11 @@ public class WlyyAgreementKpiService extends BaseJpaService<WlyyAgreementKpi, Wl
 | 
	
		
			
				|  |  |         if(wlyyAgreementKpi1==null){
 | 
	
		
			
				|  |  |             throw new ApiException(WlyyContants.Agreement.message_fail_wlyyAgreement_is_no_exist, CommonContants.common_error_params_code);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         //设置创建时间和修改时间
 | 
	
		
			
				|  |  |         Date date = new Date();
 | 
	
		
			
				|  |  |         wlyyAgreementKpi.setCreateTime(wlyyAgreementKpi1.getCreateTime());
 | 
	
		
			
				|  |  |         wlyyAgreementKpi.setUpdaateTime(date);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         wlyyAgreementKpi1 = wlyyAgreementKpiDao.findCodeExcludeId(code,id);
 | 
	
		
			
				|  |  |         if(wlyyAgreementKpi1 !=null){
 | 
	
		
			
				|  |  |             throw new ApiException(WlyyContants.Agreement.message_fail_code_exist, CommonContants.common_error_params_code);
 |