ソースを参照

中心中台融合 查询当前设备类型下的部件分类以及数量

lvxianyun 3 年 前
コミット
d062ceb90a

+ 1 - 1
dmp-business/dmp-rwd/src/main/java/com/persagy/dmp/rwd/simple/dao/EquipmentReportMapper.java

@@ -43,5 +43,5 @@ public interface EquipmentReportMapper {
      * @param equipmentId 设备ID
      * @return
      */
-    List<Map<String, Object>> queryComponentsCountByEquipId(@Param("groupCode") String groupCode,@Param("projectId") String projectId,@Param("equipmentId") String equipmentId);
+    List<Map<String, Object>> queryComponentsCountByEquipId(@Param("projectIds") List<String> projectIds,@Param("projectId") String projectId,@Param("equipmentId") String equipmentId);
 }

+ 6 - 1
dmp-business/dmp-rwd/src/main/java/com/persagy/dmp/rwd/simple/service/impl/EquipmentReportServiceImpl.java

@@ -87,7 +87,12 @@ public class EquipmentReportServiceImpl implements IEquipmentReportService {
      */
     @Override
     public List<Map<String, Object>> queryComponentsCountByEquipId(String equipmentId) {
-        return mapper.queryComponentsCountByEquipId(AppContext.getContext().getGroupCode(),AppContext.getContext().getProjectId(), equipmentId);
+        // 项目不为空,把平台级和集团级的加上
+        List<String> projectIds = new ArrayList<>();
+        projectIds.add(CommonConstant.DEFAULT_ID);
+        projectIds.add(AppContext.getContext().getGroupCode());
+        projectIds.add(AppContext.getContext().getProjectId());
+        return mapper.queryComponentsCountByEquipId(projectIds, AppContext.getContext().getProjectId(), equipmentId);
     }
 
 

+ 4 - 3
dmp-business/dmp-rwd/src/main/resources/mapper/EquipmentReportMapper.xml

@@ -98,15 +98,16 @@
         join dt_relation re on obj.id = re.obj_to
         join dt_define_type df on df.code = obj.class_code
         where obj.valid=TRUE and obj.obj_type='component' and re.rel_code='Eq2Ec'
+        and df.project_id in
+        <foreach collection="projectIds" item="projectId" open="(" close=")" separator="," >
+            #{projectId}
+        </foreach>
         <if test="null!=equipmentId and equipmentId.length>0">
             AND re.obj_from=#{equipmentId}
         </if>
         <if test="null!=projectId and projectId.length>0">
             AND obj.project_id=#{projectId}
         </if>
-        <if test="null!=groupCode and groupCode.length>0">
-            AND obj.group_code=#{groupCode}
-        </if>
         GROUP BY obj.class_code,re.obj_from,df.system_code,df.name
     </select>
 </mapper>