瀏覽代碼

Merge branch 'master' into HEAD

# Conflicts:
#	ruoyi-system/src/main/java/com/ruoyi/system/mapper/TFacilityMapper.java
#	ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TDeviceListServiceImpl.java
#	ruoyi-system/src/main/resources/mapper/system/TFacilityMapper.xml
Simon 1 年之前
父節點
當前提交
6ddc13bd43

+ 26 - 1
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/TDataDisplayController.java

@@ -20,6 +20,8 @@ import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletResponse;
 import java.text.NumberFormat;
+import java.text.SimpleDateFormat;
+import java.time.LocalDate;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -72,7 +74,7 @@ public class TDataDisplayController extends BaseController
     @GetMapping("/count")
     public AjaxResult count()
     {
-        return success(tShouhuanAlarmListService.selectTShouhuanAlarmListCount());
+        return success(userProfileService.selectuserAgeCount());
     }
 
     @GetMapping("/alarm")
@@ -139,6 +141,7 @@ public class TDataDisplayController extends BaseController
     {
         Integer total = userProfileService.selectuserAgeCount();
         List<UserAgeDto> dtoList = userProfileService.selectuserAgeDto();
+        dtoList.removeIf(user -> StringUtils.isNull(user.getAge()));
         AjaxResult ajax = new AjaxResult();
         ajax.put("list",dtoList);
         ajax.put("total", total);
@@ -197,6 +200,28 @@ public class TDataDisplayController extends BaseController
     public AjaxResult addDevice()
     {
         List<AddDeviceDto> dtoList = tDeviceListService.selectAddDevice();
+        LocalDate currentDate = LocalDate.now();
+        LocalDate lastMonthDate = currentDate.minusMonths(1);
+        int year= currentDate.getYear();
+        if (dtoList.size() == 2){
+            int lastMonth = lastMonthDate.getMonthValue()-1;
+            AddDeviceDto dto = new AddDeviceDto();
+            dto.setMonth(year + "-0" + lastMonth);
+            dto.setCount(0);
+            dtoList.add(dto);
+        }else if (dtoList.size() == 1){
+            int lastMonth = lastMonthDate.getMonthValue();
+            int lastlastMonth = lastMonthDate.getMonthValue()-1;
+            AddDeviceDto dto = new AddDeviceDto();
+            dto.setMonth(year + "-0" + lastMonth);
+            dto.setCount(0);
+            dtoList.add(dto);
+            AddDeviceDto dto1 = new AddDeviceDto();
+            dto1.setMonth(year + "-0" + lastlastMonth);
+            dto1.setCount(0);
+            dtoList.add(dto1);
+        }
+        dtoList = dtoList.stream().sorted(Comparator.comparing(AddDeviceDto::getMonth)).collect(Collectors.toList());
         return success(dtoList);
     }
 

+ 1 - 1
ruoyi-admin/src/main/resources/application-test.yml

@@ -9,7 +9,7 @@ spring:
         druid:
             # 主库数据源
             master:
-                url: jdbc:mysql://192.168.56.10:3306/yyky?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
+                url: jdbc:mysql://192.168.56.10/yyky?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
                 username: root
                 password: root
             # 从库数据源

+ 1 - 1
ruoyi-admin/src/main/resources/application.yml

@@ -54,7 +54,7 @@ spring:
     basename: i18n/messages
   profiles:
     # 测试环境
-    #    active: test
+#        active: test
     # 开发环境
     active: dev
     # 生产环境

+ 7 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/TDeviceListMapper.java

@@ -29,6 +29,13 @@ public interface TDeviceListMapper
      */
     public List<TDeviceList> selectTDeviceListList(TDeviceList tDeviceList);
 
+    /**
+     * 查询设备列列表
+     *
+     * @return 设备列集合
+     */
+    public List<TDeviceList> selectTDeviceList();
+
     /**
      * 查询设备列列表
      *

+ 7 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/TFacilityMapper.java

@@ -29,6 +29,13 @@ public interface TFacilityMapper {
      */
     public List<TFacility> selectTDeviceListListByDeviceId(String device_id_code);
 
+    /* 查询手环设备
+     *
+     * @param code 手环设备
+     * @return 手环设备
+     */
+    public TFacility selectTFacilityByCode(String code);
+
     /**
      * 查询手环设备列表
      *

+ 18 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TDeviceListServiceImpl.java

@@ -133,6 +133,19 @@ public class TDeviceListServiceImpl implements ITDeviceListService {
      */
     @Override
     public int deleteTDeviceListByIds(Integer[] ids) {
+        List<TDeviceList> tDeviceLists = tDeviceListMapper.selectTDeviceList();
+        if (StringUtils.isNotEmpty(ids)) {
+            for (Integer id : ids) {
+                for (TDeviceList tDevice : tDeviceLists) {
+                    if (tDevice.getId().equals(id)) {
+                        TFacility tFacility = tFacilityMapper.selectTFacilityByCode(tDevice.getDeviceId());
+                        if (StringUtils.isNotNull(tFacility)) {
+                            tFacilityMapper.deleteTFacilityById(tFacility.getId());
+                        }
+                    }
+                }
+            }
+        }
         return tDeviceListMapper.deleteTDeviceListByIds(ids);
     }
 
@@ -144,6 +157,11 @@ public class TDeviceListServiceImpl implements ITDeviceListService {
      */
     @Override
     public int deleteTDeviceListById(Integer id) {
+        TDeviceList tDevice = this.selectTDeviceListById(id);
+        TFacility tFacility = tFacilityMapper.selectTFacilityByCode(tDevice.getDeviceId());
+        if (StringUtils.isNotNull(tFacility)) {
+            tFacilityMapper.deleteTFacilityById(tFacility.getId());
+        }
         return tDeviceListMapper.deleteTDeviceListById(id);
     }
 

+ 6 - 1
ruoyi-system/src/main/resources/mapper/system/TDeviceListMapper.xml

@@ -109,7 +109,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         select IFNULL(count(*),0) from t_device_list
     </select>
     <select id="selectAddDevice" resultType="com.ruoyi.system.domain.dto.AddDeviceDto">
-        SELECT DATE_FORMAT(createtime, '%Y-%m') AS month, COUNT(*) AS count FROM t_device_list GROUP BY month;
+        SELECT DATE_FORMAT(createtime, '%Y-%m') AS month, COUNT(*) AS count FROM t_device_list
+        WHERE createtime > DATE_SUB(NOW(), INTERVAL 3 MONTH)
+        GROUP BY month;
     </select>
     <select id="selectTDeviceListBandUser" resultType="java.lang.Integer">
         select count(distinct userid) from t_device_list
@@ -121,6 +123,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         left join t_shouhuan_info d on a.device_id=d.device_id_code
         where a.device_id = #{deviceId}
     </select>
+    <select id="selectTDeviceList" parameterType="TDeviceList" resultMap="TDeviceListResult">
+        <include refid="selectTDeviceListVo"/>
+    </select>
 
 
     <insert id="insertTDeviceList" parameterType="TDeviceList" useGeneratedKeys="true" keyProperty="id">

+ 4 - 8
ruoyi-system/src/main/resources/mapper/system/TUserProfileMapper.xml

@@ -146,10 +146,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <select id="selectuserAgeDto" resultType="com.ruoyi.system.domain.dto.UserAgeDto">
         SELECT
         CASE
-        WHEN age IS NULL THEN
-        '未知'
-        WHEN age &gt;= 10
-        AND age &lt; 20 THEN
+        WHEN age &lt; 20
+        THEN
         '10'
         WHEN age &gt;= 20
         AND age &lt; 30 THEN
@@ -180,10 +178,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         t_user_profile
         GROUP BY
         CASE
-        WHEN age IS NULL THEN
-        '未知'
-        WHEN age &gt;= 10
-        AND age &lt; 20 THEN
+        WHEN age &lt; 20
+        THEN
         '10'
         WHEN age &gt;= 20
         AND age &lt; 30 THEN