|
@@ -0,0 +1,124 @@
|
|
|
|
+package com.loygra.mooring.serviceImpl;
|
|
|
|
+
|
|
|
|
+import java.util.HashMap;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
+
|
|
|
|
+import javax.annotation.Resource;
|
|
|
|
+
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
+
|
|
|
|
+import com.loygra.mooring.bo.MooringShipStatistic;
|
|
|
|
+import com.loygra.mooring.bo.MooringStatistic;
|
|
|
|
+import com.loygra.mooring.bo.MooringTypeStatistic;
|
|
|
|
+import com.loygra.mooring.bo.StatisticParam;
|
|
|
|
+import com.loygra.mooring.common.CommonUtil;
|
|
|
|
+import com.loygra.mooring.common.ResponseSC;
|
|
|
|
+import com.loygra.mooring.daoImpl.BaseDaoImpl;
|
|
|
|
+import com.loygra.mooring.service.StatisticService;
|
|
|
|
+import com.loygra.mooring.util.LogUtil;
|
|
|
|
+
|
|
|
|
+@Service
|
|
|
|
+public class StatisticServiceImpl extends BaseServiceImpl implements StatisticService {
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ *
|
|
|
|
+ */
|
|
|
|
+ private static final long serialVersionUID = 4608273759432685500L;
|
|
|
|
+ @Resource(name = "baseDao")
|
|
|
|
+ private BaseDaoImpl baseDao;
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ @SuppressWarnings("unchecked")
|
|
|
|
+ public Map<String, Object> getMooringShipStatistic(StatisticParam param) {
|
|
|
|
+ Map<String, Object> resultMap = getResultMap();
|
|
|
|
+ try {
|
|
|
|
+ MooringStatistic ms = new MooringStatistic();
|
|
|
|
+ // 检索港口锚位锚地统计
|
|
|
|
+ List<MooringShipStatistic> result = baseDao.selectList("Statistic.selectMooringShipStatistic", param);
|
|
|
|
+ // 检索锚泊船舶吨位统计
|
|
|
|
+ List<MooringTypeStatistic> tons_result = baseDao.selectList("Statistic.selectMooringShipTonsTypeStatistic",
|
|
|
|
+ param);
|
|
|
|
+ // 检索锚泊船舶货物类型统计
|
|
|
|
+ List<MooringTypeStatistic> goods_result = baseDao.selectList("Statistic.selectMooringShipGoodsStatistic",
|
|
|
|
+ param);
|
|
|
|
+ // 检索锚泊船舶总量统计
|
|
|
|
+ List<MooringTypeStatistic> total_result = baseDao.selectList("Statistic.selectMooringShipTotalStatistic",
|
|
|
|
+ param);
|
|
|
|
+ // 将数据添加进去
|
|
|
|
+ for (MooringShipStatistic stat : result) {
|
|
|
|
+ // 吨位统计
|
|
|
|
+ for (MooringTypeStatistic tons : tons_result) {
|
|
|
|
+ if (stat.getHarbour_code().intValue() == tons.getHarbour_code()) {
|
|
|
|
+ stat.getShip_num_detail().put("tons_" + tons.getType(), CommonUtil.getString(tons.getNum()));
|
|
|
|
+
|
|
|
|
+ System.out.println("tons_" + tons.getType()+","+ CommonUtil.getString(tons.getNum()));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // 货物统计
|
|
|
|
+ for (MooringTypeStatistic goods : goods_result) {
|
|
|
|
+ if (stat.getHarbour_code().intValue() == goods.getHarbour_code()) {
|
|
|
|
+ stat.getShip_num_detail().put("goods_" + goods.getType(),
|
|
|
|
+ CommonUtil.getQString(goods.getNum()));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // 总量统计
|
|
|
|
+ for (MooringTypeStatistic total : total_result) {
|
|
|
|
+ if (stat.getHarbour_code().intValue() == total.getHarbour_code()) {
|
|
|
|
+ stat.setPark_total_num(total.getNum());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 船舶类型统计
|
|
|
|
+ List<MooringTypeStatistic> ship_goods_result = baseDao.selectList("Statistic.selectMooringShipTypeStatistic",
|
|
|
|
+ param);
|
|
|
|
+ Map<String, String> ship_result_map = new HashMap<String, String>();
|
|
|
|
+ float ship_result_count = 0.0f;
|
|
|
|
+ for (MooringTypeStatistic ship : ship_goods_result) {
|
|
|
|
+ ship_result_count += ship.getNum();
|
|
|
|
+ }
|
|
|
|
+ if (ship_result_count > 0) {
|
|
|
|
+ for (MooringTypeStatistic ship : ship_goods_result) {
|
|
|
|
+ ship_result_map.put("goods_" + ship.getType(),
|
|
|
|
+ String.valueOf(ship.getNum() / ship_result_count));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //
|
|
|
|
+ //
|
|
|
|
+ // 船舶吨位统计
|
|
|
|
+ List<MooringTypeStatistic> ship_tons_result = baseDao.selectList("Statistic.selectMooringShipTonStatistic",
|
|
|
|
+ param);
|
|
|
|
+ Map<String, String> ship_tons_map = new HashMap<String, String>();
|
|
|
|
+ float ship_goods_count = 0.0f;
|
|
|
|
+ for (MooringTypeStatistic ship : ship_tons_result) {
|
|
|
|
+ ship_goods_count += ship.getNum();
|
|
|
|
+ }
|
|
|
|
+ if (ship_result_count > 0) {
|
|
|
|
+ for (MooringTypeStatistic ship : ship_tons_result) {
|
|
|
|
+ ship_tons_map.put("tons_" + ship.getType(),
|
|
|
|
+ String.valueOf(ship.getNum() / ship_goods_count));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // 船舶日统计
|
|
|
|
+ List<MooringTypeStatistic> ship_day_result = baseDao.selectList("Statistic.selectMooringShipDayStatistic",
|
|
|
|
+ param);
|
|
|
|
+ // 整理,添加返回值
|
|
|
|
+ // 锚泊船舶统计
|
|
|
|
+ ms.setShip_count(result);
|
|
|
|
+ // 船舶类型统计
|
|
|
|
+ ms.setShip_goods(ship_result_map);
|
|
|
|
+ // 船舶吨位统计
|
|
|
|
+ ms.setShip_tons(ship_tons_map);
|
|
|
|
+ //日统计
|
|
|
|
+ ms.setShip_days(ship_day_result);
|
|
|
|
+ putData(resultMap, ms);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ putStatusCode(resultMap, ResponseSC.SystemSC.SYSTEM_ERROR.getCode());
|
|
|
|
+ LogUtil.errorLog(new Object[] {}, new Object[] {}, e.getMessage());
|
|
|
|
+ }
|
|
|
|
+ return resultMap;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|