7 changed files with 183 additions and 69 deletions
			
			
		| @ -0,0 +1,45 @@ | |||
| package irbs.cust.rating.controller; | |||
| 
 | |||
| import irbs.cust.rating.jpa.support.KeyValueWrapper; | |||
| import irbs.cust.rating.service.HomeService; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.RequestMapping; | |||
| import org.springframework.web.bind.annotation.RequestMethod; | |||
| import org.springframework.web.bind.annotation.ResponseBody; | |||
| import org.springframework.web.bind.annotation.RestController; | |||
| 
 | |||
| import java.util.List; | |||
| 
 | |||
| /** | |||
|  * 首页控制器 | |||
|  * @author likunming | |||
|  */ | |||
| @RestController | |||
| @RequestMapping("/api/irbs/home") | |||
| public class HomeController { | |||
| 
 | |||
| 	@Autowired | |||
| 	private HomeService homeService; | |||
| 
 | |||
| 	/** | |||
| 	 * 首页,敞口分布统计 | |||
| 	 * | |||
| 	 * @throws Exception 异常 | |||
| 	 */ | |||
| 	@RequestMapping(value = "ratingModelExposure", method = RequestMethod.GET) | |||
| 	@ResponseBody | |||
| 	public List<KeyValueWrapper> ratingModelExposure() throws Exception { | |||
| 		return homeService.getRatingModelExposureList(); | |||
| 	} | |||
| 
 | |||
| 	/** | |||
| 	 * 首页,评级分布统计 | |||
| 	 * | |||
| 	 * @throws Exception 异常 | |||
| 	 */ | |||
| 	@RequestMapping(value = "ratingLevelExposure", method = RequestMethod.GET) | |||
| 	@ResponseBody | |||
| 	public List<KeyValueWrapper> ratingLevelExposureList() throws Exception { | |||
| 		return homeService.getRatingLevelExposureList(); | |||
| 	} | |||
| } | |||
| @ -0,0 +1,17 @@ | |||
| package irbs.cust.rating.service; | |||
| 
 | |||
| import irbs.cust.rating.jpa.support.KeyValueWrapper; | |||
| 
 | |||
| import java.util.List; | |||
| 
 | |||
| /** | |||
|  * 客户评级流程处理服务 | |||
|  * @author likunming | |||
|  * | |||
|  */ | |||
| public interface HomeService { | |||
| 
 | |||
| 	public List<KeyValueWrapper> getRatingModelExposureList() throws Exception; | |||
| 
 | |||
| 	public List<KeyValueWrapper> getRatingLevelExposureList() throws Exception; | |||
| } | |||
| @ -0,0 +1,52 @@ | |||
| package irbs.cust.rating.service.impl; | |||
| 
 | |||
| import irbs.cust.rating.jpa.support.KeyValueWrapper; | |||
| import irbs.cust.rating.service.HomeService; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; | |||
| import org.springframework.stereotype.Service; | |||
| 
 | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| 
 | |||
| @Service | |||
| public class HomeServiceImpl implements HomeService { | |||
| 
 | |||
| 	@Autowired | |||
| 	NamedParameterJdbcTemplate namedParameterJdbcTemplate; | |||
| 
 | |||
| 	@Override | |||
| 	public List<KeyValueWrapper> getRatingModelExposureList() throws Exception { | |||
| 		String querySql = "select MODEL_NAME, count(*) MODEL_NUMBER from NS_COMPANY_RATING where MODEL_CODE IS NOT NULL "; | |||
| 		querySql += " group by MODEL_CODE, MODEL_NAME order by CAST(substr(MODEL_CODE,4) as DECIMAL) asc "; | |||
| 		List<KeyValueWrapper> query = namedParameterJdbcTemplate.query(querySql, | |||
| 				(rs, rowNum) -> { | |||
| 					KeyValueWrapper kv = new KeyValueWrapper(); | |||
| 					kv.setKey(rs.getString("MODEL_NAME")); | |||
| 					kv.setValue(rs.getString("MODEL_NUMBER")); | |||
| 					return kv; | |||
| 				}); | |||
| 		return query; | |||
| 	} | |||
| 
 | |||
| 	@Override | |||
| 	public List<KeyValueWrapper> getRatingLevelExposureList() throws Exception { | |||
| 		String querySql1 = "select p.FINAL_LEVEL,count(*) FINAL_NUMBER from (" + | |||
| 				"select distinct(cust_no) as cust_no,FINAL_LEVEL from NS_COMPANY_RATING " + | |||
| 				"WHERE cust_no is not null and FINAL_LEVEL IS NOT NULL AND RATING_STATUS = '010' "; | |||
| 		String querySql2 = "select 'D' FINAL_LEVEL, COUNT(*) FINAL_NUMBER from (" + | |||
| 				"select distinct(cust_no) as cust_no from P_IRS_DEFAULT_COGNIZANCE " + | |||
| 				"where ((VALID = '1' and DEFAULT_TYPE ='02') or (VALID <> '0' and DEFAULT_TYPE = '01')) and cust_no is not null "; | |||
| 		querySql1 += ") p GROUP BY p.FINAL_LEVEL"; | |||
| 		querySql2 += ") q"; | |||
| 		String querySql = querySql1 + "  UNION ALL " + querySql2; | |||
| 		List<KeyValueWrapper> query = namedParameterJdbcTemplate.query(querySql, | |||
| 				(rs, rowNum) -> { | |||
| 					KeyValueWrapper kv = new KeyValueWrapper(); | |||
| 					kv.setKey(rs.getString("FINAL_LEVEL")); | |||
| 					kv.setValue(rs.getString("FINAL_NUMBER")); | |||
| 					return kv; | |||
| 				}); | |||
| 		return query; | |||
| 	} | |||
| } | |||
					Loading…
					
					
				
		Reference in new issue