Prechádzať zdrojové kódy

Merge branch 'demo_' of http://123.60.19.203:8088/hitch/hitch-sb into demo_

guarantee-lsq 2 rokov pred
rodič
commit
bbe20d4e72

+ 2 - 2
platform-dao/src/main/java/com/platform/dao/mapper/sb/SbInfoMapper.java

@@ -10,6 +10,7 @@ import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Component;
 
 import java.util.List;
+import java.util.Map;
 
 
 /**
@@ -134,6 +135,5 @@ public interface SbInfoMapper extends MyMapper<SbInfo> {
 
     List<SbInfoVO> getSubSb(SbInfoDTO sbInfoDTO);
 
-
-
+    int selectCountByPosition(String positionCode);
 }

+ 4 - 4
platform-dao/src/main/resources/application-daoTest.yml

@@ -3,10 +3,10 @@ spring:
     druid:
       master:
         driver-class-name: com.mysql.cj.jdbc.Driver
-        url: jdbc:mysql://123.60.19.203:5006/hitch-sb?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8&autoReconnect=true&allowMultiQueries=true
+        url: jdbc:mysql://localhost:3306/hitch-sb?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8&autoReconnect=true&allowMultiQueries=true
         username: root
         # password: mysql?123!@MYSQL
-        password: mysql?MYSQLmoniu123
+        password: mydm888
         # password: sbgld@QYKH@$_e^mysqlv
         filters: wall,stat
         filter:
@@ -34,10 +34,10 @@ spring:
         validation-query: SELECT 'x'
       slave:
         driver-class-name: com.mysql.cj.jdbc.Driver
-        url: jdbc:mysql://123.60.19.203:5006/hitch-sb-demo?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8&autoReconnect=true&allowMultiQueries=true
+        url: jdbc:mysql://localhost:3306/hitch-sb?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8&autoReconnect=true&allowMultiQueries=true
         username: root
         #password: mysql?123!@MYSQL
-        password: mysql?MYSQLmoniu123
+        password: mydm888
         filters: wall,stat
         filter:
           stat:

+ 8 - 0
platform-dao/src/main/resources/mapper/sb/SbInfoMapper.xml

@@ -735,4 +735,12 @@ user.real_name as saveUserName,sb.repair_dept_id
             resultType="com.platform.dao.vo.sb.SbInfoVO">
             select id,name from t_sb_info where parent_id=#{id}
     </select>
+
+    <select id="selectCountByPosition" parameterType="java.lang.String"
+            resultType="java.lang.Integer">
+        select count(info.id)
+        from t_sb_info info
+        left join t_sb_position position on info.position_id = position.id
+        where position.code like concat(#{keyword},'%')
+    </select>
 </mapper>

+ 1 - 0
platform-rest/src/main/java/com/platform/rest/controller/sb/SbInfoController.java

@@ -400,6 +400,7 @@ public class SbInfoController {
         return new R<>(sbInfoService.selectVOPageByPosition(sbInfoDTO, pageNum, pageSize));
     }
 
+
     /**
      * 导入设备:
      * 新增导入,且对应的供应商、类型、等级等都已经在数据库添加好了

+ 24 - 0
platform-rest/src/main/java/com/platform/rest/controller/sb/SbPositionController.java

@@ -11,6 +11,7 @@ import com.platform.dao.util.TreeUtil;
 import com.platform.dao.vo.export.sb.ExportSbPositionVO;
 import com.platform.dao.vo.sb.SbPositionVO;
 import com.platform.rest.log.annotation.SysLog;
+import com.platform.service.sb.SbInfoService;
 import com.platform.service.sb.SbPositionService;
 import lombok.AllArgsConstructor;
 import org.springframework.security.access.prepost.PreAuthorize;
@@ -31,6 +32,7 @@ import java.util.List;
 @RequestMapping("/sb/positions")
 public class SbPositionController {
 
+    private final SbInfoService sbInfoService;
     private final SbPositionService sbPositionService;
 
     /**
@@ -159,4 +161,26 @@ public class SbPositionController {
         return new R<>(sbPositionService.getSbTreeVOList(sbPositionDTO));
     }
 
+    /**
+     * 根据位置code查询设备数量
+     *
+     * @param code 位置code
+     * @return R
+     */
+    @GetMapping("/num/code/{code}")
+    public R selectCountByPosition(@PathVariable String code) {
+        return new R<>(sbInfoService.selectCountByPosition(code));
+    }
+
+    /**
+     * 根据位置code查询设备数量,按照类别分组
+     *
+     * @param code 位置code
+     * @return R
+     */
+    @GetMapping("/num/type/{code}")
+    public R selectCountByPositionGroupBySbType(@PathVariable String code) {
+        return new R<>(sbInfoService.selectCountByPositionGroupBySbType(code));
+    }
+
 }

+ 1 - 1
platform-rest/src/main/resources/logback-spring.xml

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <configuration debug="false" scan="false">
     <springProperty scop="context" name="spring.application.name" source="spring.application.name" defaultValue=""/>
-    <springProperty scop="context" name="platform.slf4j.data" source="platform.slf4j.data" defaultValue="/home/project"/>
+    <springProperty scop="context" name="platform.slf4j.data" source="platform.slf4j.data" defaultValue="D://home//project"/>
     <springProperty scop="context" name="logstash.ip_port" source="logstash.ip_port" defaultValue=""/>
     <property name="log.path" value="${platform.slf4j.data}/logs/${spring.application.name}"/>
     <!-- 彩色日志格式 -->

+ 15 - 0
platform-service/src/main/java/com/platform/service/sb/SbInfoService.java

@@ -9,6 +9,7 @@ import com.platform.service.base.IBaseService;
 import org.springframework.web.multipart.MultipartFile;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * @Description 设备基础信息 service
@@ -151,6 +152,20 @@ public interface SbInfoService extends IBaseService<SbInfo, SbInfoDTO> {
      * @return :
      */
     MyVOPage<SbInfoVO> selectVOPageByPosition(SbInfoDTO dto, int pageNum, int pageSize);
+    /**
+     * 查询所有某个厂区的总数,包含下属位置的
+     *
+     * @param positionCode : 位置code
+     * @return :
+     */
+    int selectCountByPosition(String positionCode);
+    /**
+     * 查询所有某个位置的类型汇总数,包含下属位置的
+     *
+     * @param positionCode : 位置code
+     * @return :
+     */
+    List<Map<String, String>> selectCountByPositionGroupBySbType(String positionCode);
 
     /**
      * 复制设备信息

+ 30 - 0
platform-service/src/main/java/com/platform/service/sb/impl/SbInfoServiceImpl.java

@@ -962,6 +962,36 @@ public class SbInfoServiceImpl extends BaseServiceImpl<SbInfoMapper, SbInfo, SbI
         return mapper.selectScreenDetailVOList(model);
     }
 
+    @Override
+    public int selectCountByPosition(String positionCode) {
+        return mapper.selectCountByPosition(positionCode);
+    }
+
+    @Override
+    public List<Map<String, String>> selectCountByPositionGroupBySbType(String positionCode) {
+        Weekend<SbPosition> weekend = new Weekend<>(SbPosition.class);
+        weekend.weekendCriteria().andLike(SbPosition::getCode, positionCode + "%");
+        List<SbPosition> sbPositions = sbPositionMapper.selectByExample(weekend);
+        List<String> positionIds = sbPositions.stream().map(SbPosition::getId).collect(Collectors.toList());
+        List<SbInfoVO> sbInfoVOS = mapper.selectVOList(new SbInfoDTO().setPositionIds(positionIds));
+        List<Map<String, String>> result = new ArrayList<>();
+        if(CollectionUtil.isNotEmpty(sbInfoVOS)) {
+            Map<String, Long> stringStringMap = sbInfoVOS.stream().collect(Collectors.groupingBy(SbInfoVO::getTypeId, Collectors.counting()));
+            List<SbType> typeList = sbTypeMapper.selectAll();
+            for (SbType type : typeList) {
+                Long num = stringStringMap.get(type.getId());
+                if (num != null) {
+                    Map<String, String> map = new HashMap<>();
+                    map.put("typeId", type.getId());
+                    map.put("typeName", type.getName());
+                    map.put("num", num.toString());
+                    result.add(map);
+                }
+            }
+        }
+        return result;
+    }
+
     @Override
     public List<SbInfoVO> selectVOList(SbInfoDTO model) {
         return mapper.selectVOList(model);