//前台方法
$(function() {index_cbb.initException();});
var index_cbb = {
initException:function(){$.Ajax({url : ctx+"/spcpvalue/cpValueAnalysis.shtml",type : 'get',success : function(data) {var day_data = data.row;console.log(day_data);var bathroomIDs = [ "cptotal_sum", "pbtotal_sum" ];//2个曲线var bathroomNames = [ "出片金额(元)", "排版金额(元)" ];//曲线值名称new Morris.Line({element: 'graph',data: day_data,xkey: 'date_str',//日期 x轴ykeys: ['cptotal_sum','pbtotal_sum'], //Y轴显示的数据labels: bathroomNames});}});}
}
//后台方法
/*** 出片和排版计价分析* @return* @PRoject_Name security_publish* @Date 2017年3月2日* @author 胡跃强*/@RecordLog(description = "出片和排版计价分析")@RequestMapping(value = "cpValueAnalysis", produces = "application/json;charset=UTF-8")@ResponseBodypublic String cpValueAnalysis(){JSONObject result = new JSONObject();Set<ValuationAnalysis> set =new TreeSet<ValuationAnalysis>();Date date = new Date();try {Map<String, Object> map = new HashMap<>();Integer press_id = SecurityCommonUtils.getCurrentUser().getPress_id();map.put("press_id",press_id);List<ValuationAnalysis> lists = spCpValueService.selectSpCpValueAnalysis(map);List<ValuationAnalysis> listpub = pubValuationService.selectPbvaluationAnalysis(map);for (int i = 0; i < listpub.size(); i++) {//俩个list的值放到一起(日期相同的)for (int j = 0; j < lists.size(); j++) {if(listpub.get(i).getDate_str().equals(lists.get(j).getDate_str())){lists.get(j).setPbtotal_sum(listpub.get(i).getPbtotal_sum());}}}for (ValuationAnalysis la : lists) {//放到set集合中TreeSet会排序if(la.getCptotal_sum()!=null){}else{la.setCptotal_sum(0.0);}if(la.getPbtotal_sum()!=null){}else{la.setPbtotal_sum(0.0);}set.add(la);}Calendar calendar = Calendar.getInstance(); for (int i = 0; i < 6; i++) {//防止查的数据不完整,填充满6月数据,set会去重复calendar.setTime(date); calendar.add(Calendar.MONTH, -i);//当前时间前去一个月calendar.getTime();//一个月前的时间 String fomatDate = DateUtils.fomatDate(calendar.getTime(), "YYYY-MM");ValuationAnalysis valuationAnalysis = new ValuationAnalysis();valuationAnalysis.setDate_str(fomatDate);valuationAnalysis.setCptotal_sum(0.0);valuationAnalysis.setPbtotal_sum(0.0);set.add(valuationAnalysis);}result.put("row",set);} catch (Exception e) {e.printStackTrace();}return JSON.toJSONString(result, SerializerFeature.WriteDateUseDateFormat);}
//sql Oracle
SELECTto_char(SETTLE_DATE,'yyyy-mm') date_str,sum(total) cptotal_sumFROMSP_CP_VALUEWHERE PRESS_ID = #{press_id} andSETTLE_DATE BETWEEN ADD_MONTHS (SYSDATE ,- 6)AND SYSDATEGROUP BY to_char(SETTLE_DATE,'yyyy-mm')ORDER BY to_char(SETTLE_DATE,'yyyy-mm')
新闻热点
疑难解答