Commit 0ae2f61f9db00e4f3dd159a79cadb294a0e5fbc9

Authored by lst
1 parent 1354dc52
Exists in dev

开发:企业大屏气瓶追踪信息

backend/lpg-api/src/main/java/com/hotent/lpg/api/controller/EnterpriseLargeScreenController.java
... ... @@ -3,10 +3,9 @@ package com.hotent.lpg.api.controller;
3 3 import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
4 4 import com.hotent.base.model.CommonResult;
5 5 import com.hotent.lpg.common.model.WCzxx;
6   -import com.hotent.lpg.common.model.WQyxx;
  6 +import com.hotent.lpg.common.util.CoordinatesTransformControllerUtil;
7 7 import com.hotent.lpg.manage.manager.MCzxxManager;
8 8 import com.hotent.lpg.manage.manager.MQpxxManager;
9   -import com.hotent.lpg.manage.manager.MQyxxManager;
10 9 import io.swagger.annotations.ApiOperation;
11 10 import lombok.extern.slf4j.Slf4j;
12 11 import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -18,7 +17,6 @@ import java.util.ArrayList;
18 17 import java.util.HashMap;
19 18 import java.util.List;
20 19 import java.util.Map;
21   -import java.util.stream.Collectors;
22 20  
23 21  
24 22 /**
... ... @@ -43,7 +41,7 @@ public class EnterpriseLargeScreenController {
43 41 */
44 42 @GetMapping(value = "/info")
45 43 @ApiOperation(value = "企业大屏展示信息", httpMethod = "GET", notes = "企业大屏展示信息")
46   - public CommonResult<Object> enterpriseLargeScreenInfo(String czId) {
  44 + public CommonResult<Object> enterpriseLargeScreenInfo(String czId) throws Exception {
47 45 if (ObjectUtils.isEmpty(czId)) {
48 46 return CommonResult.error("请传入厂站信息查询");
49 47 }
... ... @@ -62,10 +60,19 @@ public class EnterpriseLargeScreenController {
62 60 ArrayList<HashMap> maps = new ArrayList<>();
63 61 for (WCzxx wCzxx : list) {
64 62 HashMap<String, String> map = new HashMap<>();
65   - map.put("label",wCzxx.getFCzmc());
66   - map.put("value",wCzxx.getId());
  63 + map.put("label", wCzxx.getFCzmc());
  64 + map.put("value", wCzxx.getId());
67 65 maps.add(map);
68 66 }
69 67 return new CommonResult(true, "操作成功").value(maps);
70 68 }
  69 +
  70 + public static void main(String[] args) throws Exception { //湖北省孝感市云梦县道桥镇群利湾
  71 + //高地地图坐标 转换为 天地图坐标
  72 + double jd = 113.755413;// 113.74676792256132
  73 + double wd = 30.83492;// 30.83621614100548
  74 +
  75 + Map<String, Double> stringDoubleMap = CoordinatesTransformControllerUtil.transformGCJ2WGS(jd, wd);
  76 + System.out.println(stringDoubleMap);
  77 + }
71 78 }
... ...
backend/lpg-common/src/main/java/com/hotent/lpg/common/model/WQpxx.java
... ... @@ -242,4 +242,10 @@ public class WQpxx extends BaseModel&lt;WQpxx&gt; {
242 242  
243 243 @TableField(exist = false)
244 244 private LocalDateTime zhlzsj;//气瓶最后流转时间
  245 +
  246 + @TableField(exist = false)
  247 + private double fJd;//经度
  248 +
  249 + @TableField(exist = false)
  250 + private double fWd;//维度
245 251 }
... ...
backend/lpg-common/src/main/java/com/hotent/lpg/common/util/CoordinatesTransformControllerUtil.java 0 → 100644
... ... @@ -0,0 +1,159 @@
  1 +package com.hotent.lpg.common.util;
  2 +
  3 +import java.util.HashMap;
  4 +import java.util.Map;
  5 +
  6 +public class CoordinatesTransformControllerUtil {
  7 +
  8 + /**
  9 + * @FileName: CoordinatesTransformControllerUtil
  10 + * @Description: 坐标转换工具类 天地图使用的是地球坐标系(WGS84); 高德地图使用的是火星坐标系(GCJ02); 百度地图使用的是百度坐标(bd09II)
  11 + * @author: <a href="mailto: myp965@126.com">myp</a>
  12 + * @create: 2020-12-23 15:36
  13 + * @Copyright: (c) 2020年 宏信动力(北京)科技有限公司
  14 + */
  15 +
  16 +
  17 + private static final double X_PI = 3.14159265358979324 * 3000.0 / 180.0;
  18 + private static final double PI = 3.14159265358979324;
  19 + // 卫星椭球坐标投影到平面地图坐标系的投影因子。 地球长半径
  20 + private static final double EARTH_MAJOR_RADIUS = 6378245.0;
  21 + // 椭球的偏心率。
  22 + private static final double ECCENTRICITY_RATIO = 0.00669342162296594323;
  23 +
  24 + /**
  25 + * @Discription: 百度坐标(bd09II)转火星坐标(GCJ02)
  26 + * @Param lat 百度坐标纬度
  27 + * @Param lon 百度坐标经度
  28 + * @Created on: 2020/12/23 15:40
  29 + * @author muyuanpei
  30 + */
  31 + public static Map<String, Double> baiduTomars(double lat, double lon) {
  32 + Map<String, Double> mars_point = new HashMap<>();
  33 + mars_point.put("lon", 0D);
  34 + mars_point.put("lat", 0D);
  35 +
  36 + double x = lon - 0.0065;
  37 + double y = lat - 0.006;
  38 + double z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * X_PI);
  39 + double theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * X_PI);
  40 + mars_point.put("lon", z * Math.cos(theta));
  41 + mars_point.put("lat", z * Math.sin(theta));
  42 + return mars_point;
  43 + }
  44 +
  45 + /**
  46 + * @Discription: 火星坐标系(GCJ02)转百度坐标系(bd09II)
  47 + * @Param gcjLat 火星坐标纬度
  48 + * @Param gcjLon 火星坐标经度
  49 + * @Created on: 2020/12/23 15:42
  50 + * @author muyuanpei
  51 + */
  52 + public static Map<String, Double> marsTobaidu(double gcjLat, double gcjLon) {
  53 + HashMap<String, Double> baidu_point = new HashMap<>();
  54 + baidu_point.put("lon", 0D);
  55 + baidu_point.put("lat", 0D);
  56 +
  57 + double x = gcjLon;
  58 + double y = gcjLat;
  59 + double z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * X_PI);
  60 + double theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * X_PI);
  61 + baidu_point.put("lon", z * Math.cos(theta) + 0.0065);
  62 + baidu_point.put("lat", z * Math.sin(theta) + 0.006);
  63 + return baidu_point;
  64 + }
  65 +
  66 + /**
  67 + * @Discription: 火星坐标系(GCJ02)转地球坐标系(WGS84)
  68 + * @Param lat 火星坐标纬度
  69 + * @Param lon 火星坐标经度
  70 + * @Created on: 2020/12/23 15:42
  71 + * @author muyuanpei
  72 + */
  73 + public static Map<String, Double> transformGCJ2WGS(double gcjLat, double gcjLon) {
  74 + Map<String, Double> map = delta(gcjLat, gcjLon);
  75 + double lat = map.get("lat");
  76 + double lon = map.get("lon");
  77 + map.get("lon");
  78 + map.put("lat", gcjLat - lat);
  79 + map.put("lon", gcjLon - lon);
  80 + return map;
  81 + }
  82 +
  83 +
  84 + private static Map delta(double lat, double lon) {
  85 + double dLat = transformLat(lon - 105.0, lat - 35.0, PI);
  86 + double dLon = transformLon(lon - 105.0, lat - 35.0, PI);
  87 + double radLat = lat / 180.0 * PI;
  88 + double magic = Math.sin(radLat);
  89 + magic = 1 - ECCENTRICITY_RATIO * magic * magic;
  90 + double sqrtMagic = Math.sqrt(magic);
  91 + dLat = (dLat * 180.0) / ((EARTH_MAJOR_RADIUS * (1 - ECCENTRICITY_RATIO)) / (magic * sqrtMagic) * PI);
  92 + dLon = (dLon * 180.0) / (EARTH_MAJOR_RADIUS / sqrtMagic * Math.cos(radLat) * PI);
  93 +
  94 + Map<String, Double> map = new HashMap<>();
  95 + map.put("lat", dLat);
  96 + map.put("lon", dLon);
  97 + return map;
  98 + }
  99 +
  100 + /**
  101 + * @Discription: 地球坐标系(WGS - 84)转火星坐标系(GCJ)
  102 + * @Param wgLat 地球坐标纬度
  103 + * @Param wgLon 地球坐标经度
  104 + * @Created on: 2020/12/23 15:42
  105 + * @author muyuanpei
  106 + */
  107 + public static Map<String, Double> transform(double wgLat, double wgLon) {
  108 +
  109 + HashMap<String, Double> mars_point = new HashMap<>();
  110 + mars_point.put("lon", 0D);
  111 + mars_point.put("lat", 0D);
  112 + // 如果是国外坐标点,则直接返回传进来的坐标点
  113 + if (outOfChina(wgLon, wgLat)) {
  114 + mars_point.put("lon", wgLon);
  115 + mars_point.put("lat", wgLat);
  116 + return mars_point;
  117 + }
  118 + // 如果为国内坐标点,则计算偏移量
  119 + double dLat = transformLat(wgLon - 105.0, wgLat - 35.0, PI);
  120 + double dLon = transformLon(wgLon - 105.0, wgLat - 35.0, PI);
  121 + double radLat = wgLat / 180.0 * PI;
  122 + double magic = Math.sin(radLat);
  123 + magic = 1 - ECCENTRICITY_RATIO * magic * magic;
  124 + double sqrtMagic = Math.sqrt(magic);
  125 + dLat = (dLat * 180.0) / ((EARTH_MAJOR_RADIUS * (1 - ECCENTRICITY_RATIO)) / (magic * sqrtMagic) * PI);
  126 + dLon = (dLon * 180.0) / (EARTH_MAJOR_RADIUS / sqrtMagic * Math.cos(radLat) * PI);
  127 + mars_point.put("lon", wgLon + dLon);
  128 + mars_point.put("lat", wgLat + dLat);
  129 +
  130 + return mars_point;
  131 + }
  132 +
  133 + // 公共方法
  134 + /*判断是否在国内,不在国内则不做偏移*/
  135 + private static boolean outOfChina(double lon, double lat) {
  136 + if ((lon < 72.004 || lon > 137.8347) && (lat < 0.8293 || lat > 55.8271)) {
  137 + return true;
  138 + } else {
  139 + return false;
  140 + }
  141 + }
  142 +
  143 + private static double transformLat(double x, double y, double pi) {
  144 + double ret = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y + 0.2 * Math.sqrt(Math.abs(x));
  145 + ret += (20.0 * Math.sin(6.0 * x * pi) + 20.0 * Math.sin(2.0 * x * pi)) * 2.0 / 3.0;
  146 + ret += (20.0 * Math.sin(y * pi) + 40.0 * Math.sin(y / 3.0 * pi)) * 2.0 / 3.0;
  147 + ret += (160.0 * Math.sin(y / 12.0 * pi) + 320 * Math.sin(y * pi / 30.0)) * 2.0 / 3.0;
  148 + return ret;
  149 + }
  150 +
  151 + private static double transformLon(double x, double y, double pi) {
  152 + double ret = 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1 * Math.sqrt(Math.abs(x));
  153 + ret += (20.0 * Math.sin(6.0 * x * pi) + 20.0 * Math.sin(2.0 * x * pi)) * 2.0 / 3.0;
  154 + ret += (20.0 * Math.sin(x * pi) + 40.0 * Math.sin(x / 3.0 * pi)) * 2.0 / 3.0;
  155 + ret += (150.0 * Math.sin(x / 12.0 * pi) + 300.0 * Math.sin(x / 30.0 * pi)) * 2.0 / 3.0;
  156 + return ret;
  157 + }
  158 +
  159 +}
... ...
backend/lpg-manage/src/main/java/com/hotent/lpg/manage/dao/MQpxxDao.java
... ... @@ -7,6 +7,7 @@ import com.hotent.lpg.common.model.WQpxx;
7 7 import com.hotent.lpg.manage.vo.QpdtVo;
8 8 import org.apache.ibatis.annotations.Param;
9 9  
  10 +import java.util.HashMap;
10 11 import java.util.List;
11 12  
12 13 /**
... ... @@ -28,4 +29,8 @@ public interface MQpxxDao extends BaseMapper&lt;WQpxx&gt; {
28 29  
29 30  
30 31 int bottleNumber(@Param("czId") String czId,@Param("type")String type);
  32 +
  33 + List<HashMap> bottleTrackByCzId(String czId);
  34 +
  35 + List<WQpxx> listByCzId(String czId);
31 36 }
... ...
backend/lpg-manage/src/main/java/com/hotent/lpg/manage/manager/MQpxxManager.java
... ... @@ -120,5 +120,5 @@ public interface MQpxxManager extends BaseManager&lt;WQpxx&gt; {
120 120 * @param czId
121 121 * @return
122 122 */
123   - Object enterpriseLargeScreenInfo(String czId);
  123 + Object enterpriseLargeScreenInfo(String czId)throws Exception;
124 124 }
... ...
backend/lpg-manage/src/main/java/com/hotent/lpg/manage/manager/impl/MQpxxManagerImpl.java
... ... @@ -21,6 +21,7 @@ import com.hotent.base.util.time.DateFormatUtil;
21 21 import com.hotent.lpg.common.enums.*;
22 22 import com.hotent.lpg.common.model.*;
23 23 import com.hotent.lpg.common.util.CommonSynQpxxUtil;
  24 +import com.hotent.lpg.common.util.CoordinatesTransformControllerUtil;
24 25 import com.hotent.lpg.manage.dao.MClxxDao;
25 26 import com.hotent.lpg.manage.dao.MDdDao;
26 27 import com.hotent.lpg.manage.dao.MHyxxDao;
... ... @@ -857,7 +858,7 @@ public class MQpxxManagerImpl extends BaseManagerImpl&lt;MQpxxDao, WQpxx&gt; implement
857 858 }
858 859  
859 860 @Override
860   - public Object enterpriseLargeScreenInfo(String czId) {
  861 + public Object enterpriseLargeScreenInfo(String czId) throws Exception{
861 862 HashMap<String, Object> result = new HashMap<>();
862 863 HashMap<String, Object> stationOverview = new HashMap<>();//场站概况
863 864 HashMap<String, Object> bottleFilling = new HashMap<>();//气瓶充装
... ... @@ -865,15 +866,22 @@ public class MQpxxManagerImpl extends BaseManagerImpl&lt;MQpxxDao, WQpxx&gt; implement
865 866 HashMap<String, Object> bottleCheck = new HashMap<>();//气瓶检验
866 867 HashMap<String, Object> userscale = new HashMap<>();//用户规模
867 868 HashMap<String, Object> employees = new HashMap<>();//从业人员
  869 + List<HashMap> bottleTrack = new ArrayList<>();//气瓶追踪
868 870  
869 871  
870   - List<WQpxx> list = this.list(Wrappers.<WQpxx>lambdaQuery().eq(WQpxx::getFSsczid, czId));
  872 +// List<WQpxx> list = this.list(Wrappers.<WQpxx>lambdaQuery().eq(WQpxx::getFSsczid, czId));
  873 + List<WQpxx> list = this.listByCzId(czId);
871 874 Map<String, List<WQpxx>> zt_map_temp = list.stream().collect(Collectors.groupingBy(WQpxx::getFZt));//绿码、黄码、红码
872 875 Map<String, List<WQpxx>> zt_map = new HashMap<>();
873 876 zt_map.put("type1", ObjectUtils.isNotEmpty(zt_map_temp.get("正常")) ? zt_map_temp.get("正常") : new ArrayList<>());
874 877 zt_map.put("type2", ObjectUtils.isNotEmpty(zt_map_temp.get("超期未检")) ? zt_map_temp.get("超期未检") : new ArrayList<>());
875 878 zt_map.put("type3", ObjectUtils.isNotEmpty(zt_map_temp.get("报废")) ? zt_map_temp.get("报废") : new ArrayList<>());
876   -
  879 + List<WQpxx> type1 = zt_map.get("type1");
  880 + List<WQpxx> type2 = zt_map.get("type2");
  881 + List<WQpxx> type3 = zt_map.get("type3");
  882 + latlonConversion(type1);
  883 + latlonConversion(type2);
  884 + latlonConversion(type3);
877 885 int stationNumber = wCzxxManager.count();
878 886 String yearFilling = mCzglManager.yearFilling(czId);
879 887 int employeeNumber = mYgxxManager.countByCzId(czId,null);
... ... @@ -926,6 +934,8 @@ public class MQpxxManagerImpl extends BaseManagerImpl&lt;MQpxxDao, WQpxx&gt; implement
926 934 userscale.put("userType1Number", userTypeNumber.get("jm"));//居民会员数量
927 935 userscale.put("userType2Number", userTypeNumber.get("fjm"));//非居民会员数量
928 936  
  937 + bottleTrack = mQpxxDao.bottleTrackByCzId(czId);
  938 +
929 939  
930 940 //查看寻这个企业的员工、查询角色id,在查询
931 941 List<String> userIdList = mYgxxManager.userIdByCzId(czId);
... ... @@ -967,10 +977,31 @@ public class MQpxxManagerImpl extends BaseManagerImpl&lt;MQpxxDao, WQpxx&gt; implement
967 977 result.put("bottleCheck", bottleCheck);
968 978 result.put("userscale", userscale);
969 979 result.put("Employees", employees);
  980 + result.put("bottleTrack", bottleTrack);
970 981 return result;
971 982 }
972 983  
973 984 /**
  985 + * 经纬度转换
  986 + * @param type
  987 + */
  988 + private void latlonConversion(List<WQpxx> type) {
  989 + if (ObjectUtils.isNotEmpty(type)) {
  990 + for (WQpxx wQpxx : type) {
  991 + if (ObjectUtils.isNotEmpty(wQpxx.getFJd()) && ObjectUtils.isNotEmpty(wQpxx.getFWd())) {
  992 + Map<String, Double> map = CoordinatesTransformControllerUtil.transformGCJ2WGS(wQpxx.getFJd(), wQpxx.getFWd());
  993 + wQpxx.setFJd(map.get("lat"));
  994 + wQpxx.setFWd(map.get("lon"));
  995 + }
  996 + }
  997 + }
  998 + }
  999 +
  1000 + private List<WQpxx> listByCzId(String czId) {
  1001 + return baseMapper.listByCzId(czId);
  1002 + }
  1003 +
  1004 + /**
974 1005 * 不同操作类型气瓶处理
975 1006 *
976 1007 * @param qpczDTO
... ...
backend/lpg-manage/src/main/resources/mapper/MQpxxMapper.xml
... ... @@ -30,6 +30,9 @@
30 30 <result column="F_qptm" property="fQptm" />
31 31 <result column="F_zzrq" property="fZzrq" />
32 32 <result column="zhlzsj" property="zhlzsj" />
  33 +
  34 + <result column="F_jd" property="fJd" />
  35 + <result column="F_wd" property="fWd" />
33 36 </resultMap>
34 37  
35 38 <resultMap id="qpxxVoMap" type="com.hotent.lpg.manage.vo.QpxxVo">
... ... @@ -226,4 +229,34 @@
226 229 </if>
227 230 </if>
228 231 </select>
  232 +
  233 + <select id="bottleTrackByCzId" resultType="java.util.HashMap">
  234 + SELECT
  235 + CONCAT( '【气瓶#', w_qpxx.F_qptm, '】' ) AS field1,
  236 + CASE
  237 + WHEN w_qpssxx.F_cyzlx = '厂站' THEN
  238 + CONCAT( '当前位于', w_czxx.f_czmc, '扫码' )
  239 + WHEN w_qpssxx.F_cyzlx = '员工' THEN
  240 + CONCAT( '当前位于', w_czxx.f_czmc, '扫码' )
  241 + WHEN w_qpssxx.F_cyzlx = '会员' THEN
  242 + CONCAT( '当前位于用户', w_hyxx.F_xm, '扫码' )
  243 + END AS field2,
  244 + DATE_FORMAT(w_qpssxx.F_gxsj,'%Y年%m月%d日%H:%m:%s') AS field3
  245 + FROM
  246 + w_qpxx
  247 + INNER JOIN w_qpssxx ON w_qpxx.id_ = w_qpssxx.F_qpID
  248 + LEFT JOIN w_czxx ON w_qpssxx.F_cyczID = w_czxx.ID_
  249 + LEFT JOIN w_hyxx ON w_hyxx.F_userID = w_qpssxx.F_cyyhID
  250 + where w_qpxx.F_ssczID = #{czId}
  251 + </select>
  252 +
  253 + <select id="listByCzId" resultMap="BaseResultMap">
  254 + select
  255 + w_qpxx.*,
  256 + w_qpssxx.F_jd,
  257 + w_qpssxx.F_wd
  258 + from w_qpxx
  259 + inner join w_qpssxx ON w_qpxx.id_ = w_qpssxx.F_qpID
  260 + where w_qpxx.F_ssczID = #{czId}
  261 + </select>
229 262 </mapper>
... ...