hfxc226 il y a 2 ans
Parent
commit
5fbba95b65

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

@@ -140,4 +140,10 @@ public interface SbInfoMapper extends MyMapper<SbInfo> {
 
     // 根据位置code,查询该位置设备数量,包括下属位置
     List<Map<String, String>> selectCountByPositionGroup();
+
+    // 根据位置code,查询该位置设备数量,包括下属位置
+    List<Map<String, String>> selectCountByStatusGroup(String positionCode);
+
+    // 根据位置code,查询该位置设备数量,包括下属位置
+    List<Map<String, String>> selectCountByUseTypeGroup(String positionCode);
 }

+ 23 - 2
platform-dao/src/main/resources/mapper/sb/SbInfoMapper.xml

@@ -741,16 +741,37 @@ user.real_name as saveUserName,sb.repair_dept_id
         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},'%')
+        where position.code like concat(#{code},'%')
     </select>
 
     <select id="selectCountByPositionGroup" parameterType="java.lang.String"
             resultType="java.util.Map">
-        select position.id, position.name, position.code, position.type, position.parent_id parentId, count(info.id) as num
+        select position.id, position.name, position.code, position.type, position.parent_id parentId,
+               count(info.id) as num
         from t_sb_position position
         left join t_sb_info info on info.position_id=position.id
         where position.type in (1, 2) and position.del_flag=0
         group By position.id
     </select>
 
+    <select id="selectCountByStatusGroup" parameterType="java.lang.String"
+            resultType="java.util.Map">
+        select position.id,
+               info.status, count(info.id) as num
+        from t_sb_position position
+        left join t_sb_info info on info.position_id=position.id
+        where position.code like concat(#{code},'%') and position.del_flag=0
+        group By info.status
+    </select>
+
+    <select id="selectCountByUseTypeGroup" parameterType="java.lang.String"
+            resultType="java.util.Map">
+        select position.id,
+               info.use_type useType, count(info.id) as num
+        from t_sb_position position
+        left join t_sb_info info on info.position_id = position.id
+        where position.code like concat(#{code},'%') and position.del_flag=0
+        group By info.use_type
+    </select>
+
 </mapper>

+ 87 - 0
platform-rest/src/main/java/com/platform/rest/controller/sb/SbCountController.java

@@ -0,0 +1,87 @@
+package com.platform.rest.controller.sb;
+
+import com.platform.common.bean.AbstractPageResultBean;
+import com.platform.common.util.BeanConverterUtil;
+import com.platform.common.util.R;
+import com.platform.common.validation.group.AddGroup;
+import com.platform.common.validation.group.UpdateGroup;
+import com.platform.dao.dto.sb.SbInfoDTO;
+import com.platform.dao.entity.sb.SbInfo;
+import com.platform.dao.util.ExcelUtil;
+import com.platform.dao.util.TreeUtil;
+import com.platform.dao.vo.export.sb.ExportSbInfoMeasureVO;
+import com.platform.dao.vo.export.sb.ExportSbInfoVO;
+import com.platform.dao.vo.sb.SbInfoVO;
+import com.platform.dao.vo.sb.SbInfoWorkplaceVO;
+import com.platform.office.poi.excel.ExcelImportUtil;
+import com.platform.office.poi.excel.entity.ImportParams;
+import com.platform.rest.log.annotation.SysLog;
+import com.platform.service.sb.SbInfoService;
+import com.platform.service.sb.impl.SbInfoServiceImpl;
+import lombok.AllArgsConstructor;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * @Description 设备台账
+ * @Author liuyu
+ * @Date 2020-04-21 21:05:46
+ * @Version Copyright (c) 2019,北京乾元坤和科技有限公司 All rights reserved.
+ */
+@RestController
+@AllArgsConstructor
+@RequestMapping("/sb/counts")
+public class SbCountController {
+
+    private final SbInfoService sbInfoService;
+
+    /**
+     * 查询厂区和车间分组数据
+     *
+     * @return R
+     */
+    @GetMapping("group")
+    public R selectCountByPositionGroup() {
+        return new R<>(sbInfoService.selectCountByPositionGroup());
+    }
+    /**
+     * 根据位置code查询设备数量,按照类别分组
+     *
+     * @param code 位置code
+     * @return R
+     */
+    @GetMapping("/type/{code}")
+    public R selectCountByPositionGroupBySbType(@PathVariable String code) {
+        return new R<>(sbInfoService.selectCountByPositionGroupBySbType(code));
+    }
+
+    /**
+     * 设备状态台账
+     *
+     * @return R
+     */
+    @GetMapping("/status/{code}")
+    public R getCount(@PathVariable String code) {
+        return new R(sbInfoService.selectCountBySbStatusGroup(code));
+    }
+
+    /**
+     * 设备自定义类型台账-按照每个车间划分
+     *
+     * @param code 主键
+     * @return R
+     */
+    @GetMapping("/useType/{code}")
+    public R getById(@PathVariable String code) {
+        return new R(sbInfoService.selectCountByUseTypeGroup(code));
+    }
+
+}

+ 1 - 21
platform-rest/src/main/java/com/platform/rest/controller/sb/SbPositionController.java

@@ -162,7 +162,7 @@ public class SbPositionController {
     }
 
     /**
-     * 根据位置code查询设备数量
+     * 根据位置code查询设备数量--废弃
      *
      * @param code 位置code
      * @return R
@@ -171,25 +171,5 @@ public class SbPositionController {
     public R selectCountByPosition(@PathVariable String code) {
         return new R<>(sbInfoService.selectCountByPosition(code));
     }
-    /**
-     * 查询厂区和车间分组数据
-     *
-     * @param code 位置code
-     * @return R
-     */
-    @GetMapping("/num/group")
-    public R selectCountByPositionGroup() {
-        return new R<>(sbInfoService.selectCountByPositionGroup());
-    }
-    /**
-     * 根据位置code查询设备数量,按照类别分组
-     *
-     * @param code 位置code
-     * @return R
-     */
-    @GetMapping("/num/type/{code}")
-    public R selectCountByPositionGroupBySbType(@PathVariable String code) {
-        return new R<>(sbInfoService.selectCountByPositionGroupBySbType(code));
-    }
 
 }

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

@@ -66,6 +66,10 @@ public interface SbInfoService extends IBaseService<SbInfo, SbInfoDTO> {
      */
     void updateBatchValue(List<SbInfo> list);
 
+    List<Map<String, String>> selectCountBySbStatusGroup(String positionCode);
+
+    List<Map<String, String>> selectCountByUseTypeGroup(String positionCode);
+
     /**
      * 分页查询
      *

+ 33 - 12
platform-service/src/main/java/com/platform/service/sb/impl/SbInfoServiceImpl.java

@@ -973,29 +973,28 @@ public class SbInfoServiceImpl extends BaseServiceImpl<SbInfoMapper, SbInfo, SbI
         if(sbInfoCountMapList != null) {
             for (Map<String, String>  map: sbInfoCountMapList) {
                 // 汇总厂区的,将厂区下面的车间数量累加到上面
-                if ("1".equals(map.get("type"))) {
-                    String numStr = map.get("num");
-                    int num = 0;
-                    if(StringUtils.isEmpty(numStr)){
-                        num = 0;
-                    }else{
-                        num = Integer.valueOf(numStr);
-                    }
+                if (String.valueOf(map.get("type")).equals("1")) {
+                    int childNum = 0;
                     for (Map<String, String>  child: sbInfoCountMapList) {
                         if (map.get("id").equals(child.get("parentId"))) {
-                            String childNumStr = child.get("num");
-                            if(!StringUtils.isEmpty(numStr)){
-                                num = num + Integer.valueOf(childNumStr);
+                            String childNumStr = String.valueOf(child.get("num"));
+                            if(!StringUtils.isEmpty(childNumStr)){
+                                childNum = childNum + Integer.valueOf(childNumStr);
                             }
                         }
                     }
-                    map.put("num", num + "");
+                    map.put("childNum", childNum + "");
                 }
             }
         }
         return sbInfoCountMapList;
     }
 
+    /**
+     * 按照类型分组统计数量
+     * @param positionCode : 位置code
+     * @return
+     */
     @Override
     public List<Map<String, String>> selectCountByPositionGroupBySbType(String positionCode) {
         Weekend<SbPosition> weekend = new Weekend<>(SbPosition.class);
@@ -1021,6 +1020,28 @@ public class SbInfoServiceImpl extends BaseServiceImpl<SbInfoMapper, SbInfo, SbI
         return result;
     }
 
+    /**
+     * 查询某个车间下面的数据,状态分组统计数量
+     * @param positionCode : 位置code
+     * @return
+     */
+    @Override
+    public List<Map<String, String>> selectCountBySbStatusGroup(String positionCode) {
+        List<Map<String, String>> result = mapper.selectCountByStatusGroup(positionCode);
+        return result;
+    }
+
+    /**
+     * 按照自定义类型分组统计数量
+     * @param positionCode : 位置code
+     * @return
+     */
+    @Override
+    public List<Map<String, String>> selectCountByUseTypeGroup(String positionCode) {
+        List<Map<String, String>> result = mapper.selectCountByUseTypeGroup(positionCode);
+        return result;
+    }
+
     @Override
     public List<SbInfoVO> selectVOList(SbInfoDTO model) {
         return mapper.selectVOList(model);