Browse Source

git-svn-id: https://192.168.57.71/svn/jsgkj@1875 931142cf-59ea-a443-aa0e-51397b428577

ld_zhangdong 8 years ago
parent
commit
e10bee2d06

+ 190 - 0
gkjsjy/trunk/src/com/xt/jygl/gkyxtjyfx/jtgdzctjfx/ctl/JtgdzctzfxCtl.java

@@ -0,0 +1,190 @@
+package com.xt.jygl.gkyxtjyfx.jtgdzctjfx.ctl;
+
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import com.xt.jygl.common.BaseWebCtl;
+import com.xt.jygl.gkyxtjyfx.jtgdzctjfx.entity.JtgdzctzfxEntity;
+import com.xt.jygl.gkyxtjyfx.jtgdzctjfx.service.IJtgdzctzfxService;
+import com.xtframe.util.StringUtils;
+
+/**
+ * 交通固定资产统计分析
+ * 
+ * @author Administrator
+ *
+ */
+@Controller
+@RequestMapping(value = "/jtgdzctzfx")
+public class JtgdzctzfxCtl extends BaseWebCtl {
+	@Autowired
+	private IJtgdzctzfxService jtgdzctzfxService;
+
+	/**
+	 * 一览页面
+	 * 
+	 * @param model
+	 * @param startDate
+	 *            开始时间
+	 * @param endDate
+	 *            截止日期
+	 * @param menuid
+	 * @return
+	 */
+	@RequestMapping(value = "/main")
+	public String main(Model model, HttpServletRequest request, String zzbl, String startDate, String endDate, String menuid) {
+		String start = "";
+		String end = "";
+		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
+		Date date1 = new Date();
+		if (StringUtils.isEmpty(startDate)) {
+			start = sdf.format(date1).substring(0, 5) + "01";
+			end = sdf.format(date1);
+		}
+
+		List<JtgdzctzfxEntity> entityList = null;
+		if (StringUtils.isNotEmpty(startDate) && StringUtils.isNotEmpty(endDate)) {
+			entityList = jtgdzctzfxService.findBytjmonth(startDate, endDate);
+		} else {
+			entityList = jtgdzctzfxService.findBytjmonth(start, end);
+		}
+		// 吞吐量
+		List<String> amountList = new ArrayList<String>();
+		// 时间区间
+		List<String> dateList = new ArrayList<String>();
+		// 比率
+		List<String> bl = new ArrayList<String>();
+		String[] date;
+		int year, month;
+
+		// 比率
+		// 同比
+		if ("tb".equals(zzbl)) {
+			for (JtgdzctzfxEntity e : entityList) {
+				date = e.getId().split("-");
+				// 上一年
+				year = Integer.parseInt(date[0]) - 1;
+				month = Integer.parseInt(date[1]);
+				JtgdzctzfxEntity temp;
+				if (month < 10) {
+					temp = jtgdzctzfxService.findOne(year + "-0" + month);
+				} else {
+					temp = jtgdzctzfxService.findOne(year + "-" + month);
+				}
+				if (temp == null || e.getAmount() == 0 || temp.getAmount() == 0) {
+					bl.add("0");
+				} else {
+					bl.add("" + (int) ((e.getAmount() - temp.getAmount()) / temp.getAmount() * 100));
+				}
+				/*if (temp == null) {
+					if (e.getAmount() != 0) {
+						bl.add("100");
+					} else {
+						bl.add("0");
+					}
+				} else {
+					if (temp.getAmount() == 0) {
+						if (e.getAmount() != 0) {
+							bl.add("100");
+						} else {
+							bl.add("0");
+						}
+					} else {
+						bl.add("" + (int) ((e.getAmount() - temp.getAmount()) / temp.getAmount() * 100));
+					}
+				}*/
+			}
+		} else if ("hb".equals(zzbl)) {
+			for (int i = 0; i < entityList.size(); i++) {
+				if (i == 0) {
+					date = entityList.get(0).getId().split("-");
+					year = Integer.parseInt(date[0]);
+					month = Integer.parseInt(date[1]);
+					JtgdzctzfxEntity temp;
+					// 上一月
+					if (month == 1) {
+						year = year - 1;
+						month = 12;
+					} else {
+						month = month - 1;
+					}
+					if (month < 10) {
+						temp = jtgdzctzfxService.findOne(year + "-0" + month);
+					} else {
+						temp = jtgdzctzfxService.findOne(year + "-" + month);
+					}
+					if (temp == null || entityList.get(i).getAmount() == 0) {
+						bl.add("0");
+					} else {
+						bl.add("" + (int) ((entityList.get(i).getAmount() - temp.getAmount()) / entityList.get(i).getAmount() * 100));
+					}
+				} else {
+					if (entityList.get(i).getAmount() == 0) {
+						bl.add("0");
+					} else {
+						bl.add("" + (int) ((entityList.get(i).getAmount() - entityList.get(i - 1).getAmount()) / entityList.get(i).getAmount() * 100));
+					}
+				}
+			}
+
+		} else {
+			for (int i = 0; i < entityList.size(); i++) {
+				if (i == 0) {
+					date = entityList.get(i).getId().split("-");
+					year = Integer.parseInt(date[0]);
+					month = Integer.parseInt(date[1]);
+					JtgdzctzfxEntity temp;
+					// 上一月
+					if (month == 1) {
+						year = year - 1;
+						month = 12;
+					} else {
+						month = month - 1;
+					}
+					if (month < 10) {
+						temp = jtgdzctzfxService.findOne(year + "-0" + month);
+					} else {
+						temp = jtgdzctzfxService.findOne(year + "-" + month);
+					}
+					if (temp == null) {
+						bl.add("0");
+					} else {
+						bl.add("" + (int) ((entityList.get(i).getAmount() - temp.getAmount()) / temp.getAmount() * 100));
+					}
+				} else {
+					if (entityList.get(i - 1).getAmount() == 0 && entityList.get(i).getAmount() != 0) {
+						bl.add("100");
+					} else if (entityList.get(i).getAmount() == 0 || entityList.get(i - 1).getAmount() == 0) {
+						bl.add("0");
+					} else {
+						bl.add("" + (int) ((entityList.get(i).getAmount() - entityList.get(i - 1).getAmount()) / entityList.get(i - 1).getAmount() * 100));
+					}
+				}
+			}
+		}
+
+		// 获取时间区间
+		for (JtgdzctzfxEntity e : entityList) {
+			dateList.add("'" + e.getId() + "'");
+			amountList.add(e.getAmount() + "");
+		}
+		model.addAttribute("bl", bl);
+		model.addAttribute("amountList", amountList);
+		model.addAttribute("dateList", dateList);
+		model.addAttribute("startDate", startDate != null ? startDate : start);
+		model.addAttribute("endDate", endDate != null ? endDate : end);
+		model.addAttribute("zzbl", zzbl);
+		model.addAttribute("menuid", menuid);
+		return "gkyxtjyfx/jtgdzctzfx/jtgdzctzfx";
+
+	}
+}

+ 18 - 0
gkjsjy/trunk/src/com/xt/jygl/gkyxtjyfx/jtgdzctjfx/dao/JtgdzctzfxDao.java

@@ -0,0 +1,18 @@
+package com.xt.jygl.gkyxtjyfx.jtgdzctjfx.dao;
+
+import java.util.List;
+
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.Query;
+
+import com.xt.jygl.gkyxtjyfx.jtgdzctjfx.entity.JtgdzctzfxEntity;
+
+public interface JtgdzctzfxDao extends JpaRepository<JtgdzctzfxEntity, String>{
+
+	@Query(value = "select * from JTT_5_VIEW j where j.id >= ?1 and j.id <= ?2 order by j.id", nativeQuery = true)
+	List<JtgdzctzfxEntity> findBytjmonth(String smonth,String emonth);
+	
+	@Query(value = "select * from  JTT_5_VIEW where id = ?1 ", nativeQuery = true)
+	JtgdzctzfxEntity findOne(String id);
+	
+}

+ 38 - 0
gkjsjy/trunk/src/com/xt/jygl/gkyxtjyfx/jtgdzctjfx/entity/JtgdzctzfxEntity.java

@@ -0,0 +1,38 @@
+package com.xt.jygl.gkyxtjyfx.jtgdzctjfx.entity;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+import com.xtframe.sec.common.BaseEntity;
+@Entity
+@Table(name = "JTT_5_VIEW")
+public class JtgdzctzfxEntity implements Cloneable {
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 1L;
+
+	@Id
+	private String id;
+	
+	@Column(name = "amount")
+	private double amount;
+
+	public double getAmount() {
+		return amount;
+	}
+
+	public void setAmount(double amount) {
+		this.amount = amount;
+	}
+	
+	public String getId() {
+		return id;
+	}
+
+	public void setId(String id) {
+		this.id = id;
+	}
+}

+ 19 - 0
gkjsjy/trunk/src/com/xt/jygl/gkyxtjyfx/jtgdzctjfx/service/IJtgdzctzfxService.java

@@ -0,0 +1,19 @@
+package com.xt.jygl.gkyxtjyfx.jtgdzctjfx.service;
+
+import java.util.List;
+
+import com.xt.jygl.gkyxtjyfx.jtgdzctjfx.entity.JtgdzctzfxEntity;
+
+public interface IJtgdzctzfxService {
+
+	/**
+	 * 
+	 * @param smonth
+	 * @param emonth
+	 * @return
+	 */
+	public List<JtgdzctzfxEntity> findBytjmonth(String smonth,String emonth);
+	
+	public JtgdzctzfxEntity findOne(String id);
+	
+}

+ 26 - 0
gkjsjy/trunk/src/com/xt/jygl/gkyxtjyfx/jtgdzctjfx/service/impl/JtgdzctzfxServiceImpl.java

@@ -0,0 +1,26 @@
+package com.xt.jygl.gkyxtjyfx.jtgdzctjfx.service.impl;
+
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import com.xt.jygl.gkyxtjyfx.jtgdzctjfx.dao.JtgdzctzfxDao;
+import com.xt.jygl.gkyxtjyfx.jtgdzctjfx.entity.JtgdzctzfxEntity;
+import com.xt.jygl.gkyxtjyfx.jtgdzctjfx.service.IJtgdzctzfxService;
+@Service
+public class JtgdzctzfxServiceImpl implements IJtgdzctzfxService {
+	
+	@Autowired
+	private JtgdzctzfxDao dao;
+
+	@Override
+	public List<JtgdzctzfxEntity> findBytjmonth(String smonth, String emonth) {
+		return dao.findBytjmonth(smonth,emonth);
+	}
+
+	@Override
+	public JtgdzctzfxEntity findOne(String id) {
+		return dao.findOne(id);
+	}
+}