Browse Source

bug修改

minghao-chen 2 years ago
parent
commit
273de6be4c

+ 2 - 3
beidou-admin/src/main/java/cn/com/taiji/beidou/web/controller/ship/ShipTrackController.java

@@ -11,13 +11,11 @@ import cn.com.taiji.beidou.common.utils.poi.ExcelUtil;
 import cn.com.taiji.beidou.ship.track.domain.ShipTrackReq;
 import cn.com.taiji.beidou.ship.track.domain.ShipTrackResult;
 import cn.com.taiji.beidou.ship.track.service.ShipTrackService;
-import cn.com.taiji.beidou.ship.warning.record.domain.WarningRecordExcel;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.http.MediaType;
-import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RestController;
@@ -60,7 +58,8 @@ public class ShipTrackController extends BaseController {
 
             List<ShipTrackResult> shipTrackResults = shipTrackService.selectShipTrackDetail(req);
             ExcelUtil<ShipTrackResult> util = new ExcelUtil<ShipTrackResult>(ShipTrackResult.class);
-            AjaxResult result = util.exportExcel(shipTrackResults, "北斗轨迹-"+req.getDeviceId());
+            AjaxResult result = util.exportExcel(shipTrackResults, "北斗轨迹-"+req.getDeviceId(),
+                    "北斗ID:"+req.getDeviceId()+"在"+req.getStartTime()+" - "+req.getEndTime()+" 期间详细轨迹");
             String fileName = (String) result.get("msg");
             try {
                 if (!FileUtils.checkAllowDownload(fileName)){

+ 12 - 8
beidou-ship/src/main/java/cn/com/taiji/beidou/ship/status/service/impl/ShipStatusServiceImpl.java

@@ -38,11 +38,13 @@ public class ShipStatusServiceImpl implements ShipStatusService {
     {
         try {
             StasisShipStatistics statistics = shipStatusMapper.stasisShipTotal(shipId,deptId);
-            Double shipTotal = Double.parseDouble(statistics.getShipTotal());
 
-            statistics.setSmallDayRate(MathUtils.getHalfUp(Double.parseDouble(statistics.getSmallDay())/shipTotal*100,2));
-            statistics.setMiddleDayRate(MathUtils.getHalfUp(Double.parseDouble(statistics.getMiddleDay())/shipTotal*100,2));
-            statistics.setLargeDayRate(MathUtils.getHalfUp(Double.parseDouble(statistics.getLargeDay())/shipTotal*100,2));
+            int shipTotal = Integer.parseInt(statistics.getShipTotal());
+            if (shipTotal>0){
+                statistics.setSmallDayRate(MathUtils.getHalfUp(Double.parseDouble(statistics.getSmallDay())/shipTotal*100,2));
+                statistics.setMiddleDayRate(MathUtils.getHalfUp(Double.parseDouble(statistics.getMiddleDay())/shipTotal*100,2));
+                statistics.setLargeDayRate(MathUtils.getHalfUp(Double.parseDouble(statistics.getLargeDay())/shipTotal*100,2));
+            }
 
             return R.ok(statistics);
         }catch (Exception e){
@@ -56,10 +58,12 @@ public class ShipStatusServiceImpl implements ShipStatusService {
         try {
             OfflineShipStatistics offlineShipStatistics = shipStatusMapper.offlineShipTotal(shipId, deptId);
 
-            Double shipTotal = Double.parseDouble(offlineShipStatistics.getShipTotal());
-            offlineShipStatistics.setSmallDayRate(MathUtils.getHalfUp(Double.parseDouble(offlineShipStatistics.getSmallDay())/shipTotal*100,2));
-            offlineShipStatistics.setMiddleDayRate(MathUtils.getHalfUp(Double.parseDouble(offlineShipStatistics.getMiddleDay())/shipTotal*100,2));
-            offlineShipStatistics.setLargeDayRate(MathUtils.getHalfUp(Double.parseDouble(offlineShipStatistics.getLargeDay())/shipTotal*100,2));
+            int shipTotal = Integer.parseInt(offlineShipStatistics.getShipTotal());
+            if (shipTotal>0) {
+                offlineShipStatistics.setSmallDayRate(MathUtils.getHalfUp(Double.parseDouble(offlineShipStatistics.getSmallDay()) / shipTotal * 100, 2));
+                offlineShipStatistics.setMiddleDayRate(MathUtils.getHalfUp(Double.parseDouble(offlineShipStatistics.getMiddleDay()) / shipTotal * 100, 2));
+                offlineShipStatistics.setLargeDayRate(MathUtils.getHalfUp(Double.parseDouble(offlineShipStatistics.getLargeDay()) / shipTotal * 100, 2));
+            }
             return R.ok(offlineShipStatistics);
         }catch (Exception e){
             return R.fail(e.getMessage());

+ 2 - 0
beidou-ship/src/main/java/cn/com/taiji/beidou/ship/warning/record/service/impl/WarningRecordServiceImpl.java

@@ -60,6 +60,8 @@ public class WarningRecordServiceImpl implements WarningRecordService {
         //更新处置状态  如果处置类型是正常,则不添加标记
         if(!Constants.ZERO.equals(shipDisposeData.getDisposeType())){
             shipStatusMapper.updateMark("MARK",byId.getDeviceId());
+        }else {
+            shipStatusMapper.updateMark("ONLINE",byId.getDeviceId());
         }
         shipDisposeData.setDevideNo(byId.getDeviceId());
         return warningRecordMapper.insertDispose(shipDisposeData);

+ 12 - 8
beidou-ship/src/main/resources/mapper/ShipStatusMapper.xml

@@ -65,7 +65,7 @@
         </if>
         <if test="isStasis != null and isStasis != ''">
             and st.is_anchor = #{isStasis}
+             and TIMESTAMPDIFF(MINUTE,st.anchor_change_time,NOW())>24*60*1
         </if>
     </select>
 
@@ -73,16 +73,17 @@
         select archives.*,
         (CASE st.is_online WHEN 'ONLINE' THEN 1  WHEN 'OFFLINE' THEN 2 WHEN 'MARK' THEN 3 END) as is_online,
         st.is_inport,location.longitude,location.latitude,location.location,
-        st.online_change_time ,
         location.kwh as kwh,
         dept.pscmc as dept_name,
         <if test="isOnline != null and isOnline != ''">
+        st.online_change_time ,
         TIMESTAMPDIFF(SECOND,st.online_change_time,NOW()) as order_day,
         IF(floor(TIMESTAMPDIFF(SECOND,st.online_change_time,NOW())/24/60/60)>0,concat( floor(TIMESTAMPDIFF(SECOND,st.online_change_time,NOW())/24/60/60),'天'),
         IF(floor((TIMESTAMPDIFF(SECOND,st.online_change_time,NOW())/60/60)%24)>0,concat(floor( (TIMESTAMPDIFF(SECOND,st.online_change_time,NOW())/60/60)%24),
-        '小时'),IF(floor((TIMESTAMPDIFF(SECOND,st.online_change_time,NOW())/60)%60)>0,concat(floor( (TIMESTAMPDIFF(SECOND,st.online_change_time,NOW())/60)%60),'分钟'),""))) as number_day
+        '小时'),IF(floor((TIMESTAMPDIFF(SECOND,st.online_change_time,NOW())/60)%60)>0,concat(floor( (TIMESTAMPDIFF(SECOND,st.online_change_time,NOW())/60)%60),'分钟'),"1分钟"))) as number_day
         </if>
         <if test="isStasis != null and isStasis != ''">
+            st.anchor_change_time as online_change_time,
             TIMESTAMPDIFF(DAY,st.anchor_change_time,NOW()) as number_day
         </if>
         from ax_beidou_ship_status st
@@ -95,7 +96,7 @@
         </if>
         <if test="isStasis != null and isStasis != ''">
             and st.is_anchor = #{isStasis}
+             and TIMESTAMPDIFF(MINUTE,st.anchor_change_time,NOW())>24*60*1
         </if>
         <if test="shipId != null and shipId != ''">and (archives.ship_id like concat('%', #{shipId},'%') or archives.devide_no like concat('%', #{devideNo},'%'))</if>
         <if test="deptId != null and deptId != ''">and dept.xw_dept_id like concat('%',#{deptId},'%')</if>
@@ -124,16 +125,16 @@
 
     <select id="stasisShipTotal" parameterType="string" resultType="stasisShipStatistics">
         select count(1) as shipTotal,
-        SUM(CASE  WHEN st.anchor_change_time BETWEEN DATE_SUB(NOW(),INTERVAL 15 DAY) AND DATE_SUB(NOW(),INTERVAL 7 DAY) THEN 1 ELSE 0 END) as smallDay,
-        SUM(CASE  WHEN st.anchor_change_time BETWEEN DATE_SUB(NOW(),INTERVAL 30 DAY) AND DATE_SUB(NOW(),INTERVAL 15 DAY) THEN 1 ELSE 0 END) as middleDay,
-        SUM(CASE  WHEN st.anchor_change_time &lt; DATE_SUB(NOW(),INTERVAL 30 DAY) THEN 1 ELSE 0 END) as largeDay
+        IFNULL(SUM(CASE  WHEN st.anchor_change_time BETWEEN DATE_SUB(NOW(),INTERVAL 15 DAY) AND DATE_SUB(NOW(),INTERVAL 7 DAY) THEN 1 ELSE 0 END),'0') as smallDay,
+        IFNULL(SUM(CASE  WHEN st.anchor_change_time BETWEEN DATE_SUB(NOW(),INTERVAL 30 DAY) AND DATE_SUB(NOW(),INTERVAL 15 DAY) THEN 1 ELSE 0 END),'0') as middleDay,
+        IFNULL(SUM(CASE  WHEN st.anchor_change_time &lt; DATE_SUB(NOW(),INTERVAL 30 DAY) THEN 1 ELSE 0 END),'0') as largeDay
         from ax_beidou_ship_status st
         inner join ax_beidou_ship_archives archives on st.device_id = archives.devide_no
         <if test="deptId != null and deptId != ''">
         inner join ax_beidou_dept dept on archives.police_station_id = dept.pscbh
         </if>
         where st.is_anchor='TRUE'
+         and TIMESTAMPDIFF(MINUTE,st.anchor_change_time,NOW())>24*60*1
         <if test="shipId != null and shipId != ''">and (archives.ship_id like concat('%', #{shipId},'%') or archives.devide_no like concat('%', #{devideNo},'%'))</if>
         <if test="deptId != null and deptId != ''">and dept.xw_dept_id like concat('%',#{deptId},'%')</if>
     </select>
@@ -141,9 +142,9 @@
 
     <select id="offlineShipTotal" parameterType="string" resultType="offlineShipStatistics">
         select count(1) as shipTotal,
-        SUM(CASE  WHEN st.online_change_time BETWEEN DATE_SUB(NOW(),INTERVAL 8 DAY) AND NOW() THEN 1 ELSE 0 END) as smallDay,
-        SUM(CASE  WHEN st.online_change_time BETWEEN DATE_SUB(NOW(),INTERVAL 30 DAY) AND DATE_SUB(NOW(),INTERVAL 8 DAY) THEN 1 ELSE 0 END) as middleDay,
-        SUM(CASE  WHEN st.online_change_time &lt; DATE_SUB(NOW(),INTERVAL 30 DAY) THEN 1 ELSE 0 END) as largeDay
+        IFNULL(SUM(CASE  WHEN st.online_change_time BETWEEN DATE_SUB(NOW(),INTERVAL 8 DAY) AND NOW() THEN 1 ELSE 0 END),'0') as smallDay,
+        IFNULL(SUM(CASE  WHEN st.online_change_time BETWEEN DATE_SUB(NOW(),INTERVAL 30 DAY) AND DATE_SUB(NOW(),INTERVAL 8 DAY) THEN 1 ELSE 0 END),'0') as middleDay,
+        IFNULL(SUM(CASE  WHEN st.online_change_time &lt; DATE_SUB(NOW(),INTERVAL 30 DAY) THEN 1 ELSE 0 END),'0') as largeDay
         from ax_beidou_ship_status st
         RIGHT join ax_beidou_ship_archives archives on st.device_id = archives.devide_no
         <if test="deptId != null and deptId != ''">

+ 1 - 1
beidou-system/src/main/resources/mapper/system/SysDeptMapper.xml

@@ -44,7 +44,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 		</if>
 		<!-- 数据范围过滤 -->
 		${params.dataScope}
-		order by d.parent_id, d.order_num
+		order by d.parent_id, d.order_num DESC
     </select>
     
     <select id="selectDeptListByRoleId" resultType="Long">