
//前臺方法
$(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')
新聞熱點
疑難解答