Przeglądaj źródła

各公司看板

lipenghui 3 tygodni temu
rodzic
commit
05613fd6f9

+ 4 - 1
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotmainworkorder/vo/IotMainWorkOrderPageReqVO.java

@@ -10,6 +10,7 @@ import org.springframework.format.annotation.DateTimeFormat;
 import java.math.BigDecimal;
 import java.time.LocalDateTime;
 import java.util.List;
+import java.util.Set;
 
 import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
 
@@ -96,4 +97,6 @@ public class IotMainWorkOrderPageReqVO extends PageParam {
     private String deviceCode;
     @Schema(description = "工单id集合", example = "8684")
     private List<Long> workOrderIds;
-}
+
+    private Set<Long> deptIds;
+}

+ 2 - 1
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotopeationfill/vo/IotOpeationFillPageReqVO.java

@@ -78,4 +78,5 @@ public class IotOpeationFillPageReqVO extends PageParam {
     private Integer userId;
     private String userName;
 
-}
+    private List<Long> deptIds;
+}

+ 65 - 22
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/stat/IotStaticController.java

@@ -36,6 +36,7 @@ import cn.iocoder.yudao.module.pms.service.DeviceServiceImpl;
 import cn.iocoder.yudao.module.pms.service.inspect.IotInspectOrderService;
 import cn.iocoder.yudao.module.pms.service.maintain.IotMaintainService;
 import cn.iocoder.yudao.module.system.api.dept.DeptApi;
+import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
 import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
 import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictDataDO;
 import cn.iocoder.yudao.module.system.service.dept.DeptService;
@@ -55,6 +56,7 @@ import javax.annotation.Resource;
 import javax.annotation.security.PermitAll;
 import javax.validation.Valid;
 import java.io.Serializable;
+import java.sql.Array;
 import java.sql.Timestamp;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
@@ -239,12 +241,21 @@ public class IotStaticController {
         return CommonResult.success(order);
     }
 
+    @GetMapping("/inspect/statuss/{dept}")
+    public CommonResult<Map<String, Long>> getInspectStatusInfos(@PathVariable("dept") String dept) {
+        Set<Long> ids = getDeptIds(dept);
+        IotCountDataDO vo = new IotCountDataDO();
+        List<IotInspectOrderDO> iotInspectOrderDOS = iotInspectOrderMapper.selectListStat(vo, ids);
+        Map<String, Long> order = iotInspectOrderDOS.stream().collect(Collectors.groupingBy(IotInspectOrderDO::getStatus, Collectors.counting()));
+        return CommonResult.success(order);
+    }
+
     @GetMapping("/inspect/today/status")
     public CommonResult<Map<String, Long>> getInspectTodayStatusInfo() {
         ImmutableMap<String, LocalDateTime> beginEndDay = DateUtils.getBeginEndDay(0);
         IotInspectOrderPageReqVO iotInspectOrderPageReqVO = new IotInspectOrderPageReqVO();
         iotInspectOrderPageReqVO.setCreateTime(new LocalDateTime[]{beginEndDay.get("start"), beginEndDay.get("end")});
-        List<IotInspectOrderDO> iotInspectOrderDOS = iotInspectOrderMapper.selectListByCreateTime(iotInspectOrderPageReqVO);
+        List<IotInspectOrderDO> iotInspectOrderDOS = iotInspectOrderMapper.selectListByCreateTime(iotInspectOrderPageReqVO, new HashSet<>());
         Map<String, Long> order = iotInspectOrderDOS.stream().collect(Collectors.groupingBy(IotInspectOrderDO::getStatus, Collectors.counting()));
         return CommonResult.success(order);
     }
@@ -308,9 +319,12 @@ public class IotStaticController {
         return CommonResult.success(ImmutableMap.of("total", total,"todo", todo));
     }
 
-    @GetMapping("/maintenance/status")
-    public CommonResult<Map<String, Long>> getMaintenanceStatusInfo() {
-        List<IotMainWorkOrderDO> iotMainWorkOrderDOS = iotMainWorkOrderMapper.selectList();
+    @GetMapping("/maintenance/status/{dept}")
+    public CommonResult<Map<String, Long>> getMaintenanceStatusInfo(@PathVariable("dept") String dept) {
+        Set<Long> ids = getDeptIds(dept);
+        IotMainWorkOrderPageReqVO reqVO = new IotMainWorkOrderPageReqVO();
+        reqVO.setDeptIds(ids);
+        List<IotMainWorkOrderDO> iotMainWorkOrderDOS = iotMainWorkOrderMapper.selectList(reqVO);
         Map<Integer, Long> order = iotMainWorkOrderDOS.stream().collect(Collectors.groupingBy(IotMainWorkOrderDO::getResult, Collectors.counting()));
         Map<String, Long> resultMap = new HashMap<>(order.size());
         order.forEach((k,v)->{
@@ -328,7 +342,7 @@ public class IotStaticController {
         ImmutableMap<String, LocalDateTime> beginEndDay = DateUtils.getBeginEndDay(0);
         IotMainWorkOrderPageReqVO iotMainWorkOrderPageReqVO = new IotMainWorkOrderPageReqVO();
         iotMainWorkOrderPageReqVO.setCreateTime(new LocalDateTime[]{beginEndDay.get("start"), beginEndDay.get("end")});
-        List<IotMainWorkOrderDO> iotInspectOrderDOS = iotMainWorkOrderMapper.selectListByCreateTime(iotMainWorkOrderPageReqVO);
+        List<IotMainWorkOrderDO> iotInspectOrderDOS = iotMainWorkOrderMapper.selectListByCreateTime(iotMainWorkOrderPageReqVO, new HashSet<>());
         Map<Integer, Long> order = iotInspectOrderDOS.stream().collect(Collectors.groupingBy(IotMainWorkOrderDO::getResult, Collectors.counting()));
         Map<String, Long> resultMap = new HashMap<>(order.size());
         order.forEach((k,v)->{
@@ -392,10 +406,29 @@ public class IotStaticController {
 
     }
 
+    private Set<Long> getDeptIds(String dept) {
+        Set<Long> ids = new HashSet<>();
+        List<DeptRespDTO> depts = new ArrayList<>();
+        if ("rd".equals(dept)) {
+            depts = deptApi.getDeptByName("四川瑞都");
+        } else if ("rh".equals(dept)) {
+            depts = deptApi.getDeptByName("瑞恒兴域");
+        } else if ("ry".equals(dept)) {
+            depts = deptApi.getDeptByName("瑞鹰国际");
+        }
+        if (CollUtil.isNotEmpty(depts)) {
+            if (Objects.nonNull(depts.get(0).getId())) {
+                ids = deptService.getChildDeptIdListFromCache(depts.get(0).getId());
+                ids.add(depts.get(0).getId());
+            }
+        }
+        return  ids;
+    }
 
-    @GetMapping("/home/device/count")
-    public CommonResult<ImmutableMap<Object, Object>> getHomeDeviceCountStat() {
-        Long deviceCount = iotDeviceMapper.selectCount();
+    @GetMapping("/home/device/count/{dept}")
+    public CommonResult<ImmutableMap<Object, Object>> getHomeDeviceCountStat(@PathVariable("dept") String dept) {
+        Set<Long> ids = getDeptIds(dept);
+        Long deviceCount = iotDeviceMapper.selectByDept(ids);
         ImmutableMap<String, LocalDateTime> beginEndDay = DateUtils.getBeginEndDay(0);
         IotDevicePageReqVO iotDevicePageReqVO = new IotDevicePageReqVO();
         iotDevicePageReqVO.setCreateTime(new LocalDateTime[]{beginEndDay.get("start"), beginEndDay.get("end")});
@@ -403,10 +436,12 @@ public class IotStaticController {
         return CommonResult.success(ImmutableMap.of("total", deviceCount,"today", deviceToday));
     }
 
-    @GetMapping("/home/maintain/count")
-    public CommonResult<ImmutableMap<Object, Object>> getHomeMaintainCountStat() {
+    @GetMapping("/home/maintain/count/{dept}")
+    public CommonResult<ImmutableMap<Object, Object>> getHomeMaintainCountStat(@PathVariable("dept") String dept) {
         ImmutableMap<String, LocalDateTime> beginEndDay = DateUtils.getBeginEndDay(0);
-        Long maintainCount = iotMaintainMapper.selectCount();
+        Set<Long> ids = getDeptIds(dept);
+
+        Long maintainCount = iotMaintainMapper.selectByDept(ids);
         IotMaintainPageReqVO iotMaintainPageReqVO = new IotMaintainPageReqVO();
         iotMaintainPageReqVO.setCreateTime(new LocalDateTime[]{beginEndDay.get("start"), beginEndDay.get("end")});
         Long maintainToday = iotMaintainMapper.selectCountByTimeAndStatus(iotMaintainPageReqVO);
@@ -435,9 +470,12 @@ public class IotStaticController {
 
     @Resource
     private DictDataService dictDataService;
-    @GetMapping("/home/device/status")
-    public CommonResult<List<Map<String, Object>>> getDeviceStatusStat() {
-        List<IotDeviceDO> iotDeviceDOS = iotDeviceMapper.selectList();
+    @GetMapping("/home/device/status/{dept}")
+    public CommonResult<List<Map<String, Object>>> getDeviceStatusStat(@PathVariable("dept") String dept) {
+        Set<Long> ids = getDeptIds(dept);
+        IotDevicePageReqVO iotDevicePageReqVO = new IotDevicePageReqVO();
+        iotDevicePageReqVO.setDeviceIds(new ArrayList<>(ids));
+        List<IotDeviceDO> iotDeviceDOS = iotDeviceMapper.selectList(iotDevicePageReqVO);
         Map<String, Long> order = iotDeviceDOS.stream().collect(Collectors.groupingBy(IotDeviceDO::getDeviceStatus, Collectors.counting()));
         List<Map<String, Object>> results = new ArrayList<>();
         List<DictDataDO> pmsDeviceStatus = dictDataService.getDictDataListByDictType("pms_device_status");
@@ -452,9 +490,12 @@ public class IotStaticController {
         return CommonResult.success(results);
     }
 
-    @GetMapping("/home/device/type")
-    public CommonResult<List<Map<String, Object>>> getDeviceTypeStat() {
-        List<IotDeviceDO> iotDeviceDOS = iotDeviceMapper.selectList();
+    @GetMapping("/home/device/type/{dept}")
+    public CommonResult<List<Map<String, Object>>> getDeviceTypeStat(@PathVariable("dept") String dept) {
+        Set<Long> ids = getDeptIds(dept);
+        IotDevicePageReqVO iotDevicePageReqVO = new IotDevicePageReqVO();
+        iotDevicePageReqVO.setDeviceIds(new ArrayList<>(ids));
+        List<IotDeviceDO> iotDeviceDOS = iotDeviceMapper.selectList(iotDevicePageReqVO);
         List<Map.Entry<Long, Long>> collect = iotDeviceDOS.stream().collect(Collectors.groupingBy(IotDeviceDO::getAssetClass, Collectors.counting())).entrySet().stream().sorted(Map.Entry.<Long, Long>comparingByValue().reversed())
                 .limit(5)
                 .collect(Collectors.toList());
@@ -523,9 +564,10 @@ public class IotStaticController {
         return success(ImmutableMap.of("todo", todo.get(),"finished", finished.get()));
     }
 
-    @GetMapping("/rh/order")
+    @GetMapping("/rh/order/{dept}")
     @PermitAll
-    public CommonResult<Map<String, Object>> getOrderNumberStat() {
+    public CommonResult<Map<String, Object>> getOrderNumberStat(@PathVariable("dept") String dept) {
+        Set<Long> ids = getDeptIds(dept);
         List<String> lastSevenDays = DateUtils.getLastSevenDays();
         String first = lastSevenDays.get(0);
         String last = lastSevenDays.get(lastSevenDays.size() - 1);
@@ -535,6 +577,7 @@ public class IotStaticController {
 
         IotOpeationFillPageReqVO iotOpeationFillPageReqVO = new IotOpeationFillPageReqVO();
         iotOpeationFillPageReqVO.setCreateTime(createTime);
+        iotOpeationFillPageReqVO.setDeptIds(new ArrayList<>(ids));
         List<Map<String, Object>> fills = iotOpeationFillMapper.selectListByCreateTime(iotOpeationFillPageReqVO).stream().map(e -> {
             Map<String, Object> abc = new HashMap<>();
             abc.put("id", e.getId());
@@ -551,7 +594,7 @@ public class IotStaticController {
 
         IotMaintainPageReqVO iotMaintainPageReqVO = new IotMaintainPageReqVO();
         iotMaintainPageReqVO.setCreateTime(createTime);
-        List<Map<String, Object>> maintains = iotMaintainMapper.selectListByCreateTime(iotMaintainPageReqVO).stream().map(e -> {
+        List<Map<String, Object>> maintains = iotMaintainMapper.selectListByCreateTime(iotMaintainPageReqVO, ids).stream().map(e -> {
             Map<String, Object> abc = new HashMap<>();
             abc.put("id", e.getId());
             abc.put("createTime", e.getCreateTime());
@@ -565,7 +608,7 @@ public class IotStaticController {
 
         IotMainWorkOrderPageReqVO iotMainWorkOrderPageReqVO = new IotMainWorkOrderPageReqVO();
         iotMainWorkOrderPageReqVO.setCreateTime(createTime);
-        List<Map<String, Object>> works = iotMainWorkOrderMapper.selectListByCreateTime(iotMainWorkOrderPageReqVO).stream().map(e -> {
+        List<Map<String, Object>> works = iotMainWorkOrderMapper.selectListByCreateTime(iotMainWorkOrderPageReqVO,ids).stream().map(e -> {
             Map<String, Object> abc = new HashMap<>();
             abc.put("id", e.getId());
             abc.put("createTime", e.getCreateTime());
@@ -580,7 +623,7 @@ public class IotStaticController {
 
         IotInspectOrderPageReqVO iotInspectOrderPageReqVO = new IotInspectOrderPageReqVO();
         iotInspectOrderPageReqVO.setCreateTime(createTime);
-        List<Map<String, Object>> inspects = iotInspectOrderMapper.selectListByCreateTime(iotInspectOrderPageReqVO).stream().map(e -> {
+        List<Map<String, Object>> inspects = iotInspectOrderMapper.selectListByCreateTime(iotInspectOrderPageReqVO,ids).stream().map(e -> {
             Map<String, Object> abc = new HashMap<>();
             abc.put("id", e.getId());
             abc.put("createTime", e.getCreateTime());

+ 5 - 1
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/mysql/IotDeviceMapper.java

@@ -17,6 +17,7 @@ import org.apache.ibatis.annotations.Update;
 
 import java.util.Collection;
 import java.util.List;
+import java.util.Set;
 
 /**
  * 设备台账 Mapper
@@ -168,7 +169,10 @@ public interface IotDeviceMapper extends BaseMapperX<IotDeviceDO> {
         return selectList(new LambdaQueryWrapperX<IotDeviceDO>()
                 .in(IotDeviceDO::getDeviceCode, codes));
     }
-
+    default Long selectByDept(Set<Long> ids) {
+        return selectCount(new LambdaQueryWrapperX<IotDeviceDO>()
+                .inIfPresent(IotDeviceDO::getDeptId, ids));
+    }
     /* default PageResult<IotDeviceDO> deviceAssociateBomPage(IotDevicePageReqVO reqVO, Collection<Long> deptIds) {
         MPJLambdaWrapperX<IotDeviceDO> query = new MPJLambdaWrapperX<IotDeviceDO>();
         query.innerJoin(IotBomDO.class, IotBomDO::getDeviceCategoryId, IotDeviceDO::getAssetClass)

+ 2 - 2
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/mysql/inspect/IotInspectOrderMapper.java

@@ -58,9 +58,9 @@ public interface IotInspectOrderMapper extends BaseMapperX<IotInspectOrderDO> {
                 .eqIfPresent(IotInspectOrderDO::getStatus, reqVO.getStatus())
                 .betweenIfPresent(IotInspectOrderDO::getCreateTime, reqVO.getCreateTime()));
     }
-    default List<IotInspectOrderDO> selectListByCreateTime(IotInspectOrderPageReqVO reqVO) {
+    default List<IotInspectOrderDO> selectListByCreateTime(IotInspectOrderPageReqVO reqVO, Set<Long> ids) {
         return selectList(new LambdaQueryWrapperX<IotInspectOrderDO>()
-                .betweenIfPresent(IotInspectOrderDO::getCreateTime, reqVO.getCreateTime())
+                .betweenIfPresent(IotInspectOrderDO::getCreateTime, reqVO.getCreateTime()).inIfPresent(IotInspectOrderDO::getDeptId,ids)
                 .orderByAsc(IotInspectOrderDO::getCreateTime));
     }
 

+ 4 - 3
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/mysql/iotmainworkorder/IotMainWorkOrderMapper.java

@@ -15,6 +15,7 @@ import org.apache.ibatis.annotations.Select;
 import java.util.Collection;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 /**
  * 保养工单 Mapper
@@ -54,7 +55,7 @@ public interface IotMainWorkOrderMapper extends BaseMapperX<IotMainWorkOrderDO>
                 .inIfPresent(IotMainWorkOrderDO::getId, reqVO.getWorkOrderIds())
                 .eqIfPresent(IotMainWorkOrderDO::getPlanId, reqVO.getPlanId())
                 .eqIfPresent(IotMainWorkOrderDO::getPlanSerialNumber, reqVO.getPlanSerialNumber())
-                .eqIfPresent(IotMainWorkOrderDO::getDeptId, reqVO.getDeptId())
+                .eqIfPresent(IotMainWorkOrderDO::getDeptId, reqVO.getDeptIds())
                 .eqIfPresent(IotMainWorkOrderDO::getOrderNumber, reqVO.getOrderNumber())
                 .likeIfPresent(IotMainWorkOrderDO::getName, reqVO.getName())
                 .eqIfPresent(IotMainWorkOrderDO::getType, reqVO.getType())
@@ -83,9 +84,9 @@ public interface IotMainWorkOrderMapper extends BaseMapperX<IotMainWorkOrderDO>
                 .eqIfPresent(IotMainWorkOrderDO::getResult, reqVO.getResult())
                 .betweenIfPresent(IotMainWorkOrderDO::getCreateTime, reqVO.getCreateTime()));
     }
-    default List<IotMainWorkOrderDO> selectListByCreateTime(IotMainWorkOrderPageReqVO reqVO) {
+    default List<IotMainWorkOrderDO> selectListByCreateTime(IotMainWorkOrderPageReqVO reqVO, Set<Long> ids) {
         return selectList(new LambdaQueryWrapperX<IotMainWorkOrderDO>()
-                .betweenIfPresent(IotMainWorkOrderDO::getCreateTime, reqVO.getCreateTime())
+                .betweenIfPresent(IotMainWorkOrderDO::getCreateTime, reqVO.getCreateTime()).inIfPresent(IotMainWorkOrderDO::getDeptId, ids)
                 .orderByAsc(IotMainWorkOrderDO::getCreateTime));
     }
 

+ 8 - 2
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/mysql/maintain/IotMaintainMapper.java

@@ -18,6 +18,7 @@ import org.apache.ibatis.annotations.Param;
 
 import java.util.Collection;
 import java.util.List;
+import java.util.Set;
 
 /**
  * 维修工单 Mapper
@@ -72,6 +73,11 @@ public interface IotMaintainMapper extends BaseMapperX<IotMaintainDO> {
                 .betweenIfPresent(IotMaintainDO::getCreateTime, reqVO.getCreateTime()));
     }
 
+    default Long selectByDept(Set<Long> ids) {
+        return selectCount(new LambdaQueryWrapperX<IotMaintainDO>()
+                .inIfPresent(IotMaintainDO::getDeptId, ids));
+    }
+
     default List<IotMaintainDO> selectByStatusAndAuditStatusAndDeviceId(String status, Integer auditStatus, List<Long> deviceIds) {
         return selectList(new LambdaQueryWrapperX<IotMaintainDO>()
                 .eq(IotMaintainDO::getStatus, status)
@@ -79,8 +85,8 @@ public interface IotMaintainMapper extends BaseMapperX<IotMaintainDO> {
                 .in(IotMaintainDO::getDeviceId, deviceIds));
     }
     IPage<OrderVo> selectNotice(IPage<OrderVo> page, @Param("reqVO")OrderVo reqVO);
-    default List<IotMaintainDO> selectListByCreateTime(IotMaintainPageReqVO reqVO) {
+    default List<IotMaintainDO> selectListByCreateTime(IotMaintainPageReqVO reqVO, Set<Long> ids) {
         return selectList(new LambdaQueryWrapperX<IotMaintainDO>()
-                .betweenIfPresent(IotMaintainDO::getCreateTime, reqVO.getCreateTime()));
+                .betweenIfPresent(IotMaintainDO::getCreateTime, reqVO.getCreateTime()).inIfPresent(IotMaintainDO::getDeptId, ids));
     }
 }

+ 6 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/resources/mapper/static/IotOpeationFillMapper.xml

@@ -277,6 +277,12 @@
         SELECT a.id, a.create_time
         FROM rq_iot_opeation_fill_order a
         WHERE a.create_time BETWEEN #{createTime[0],typeHandler=org.apache.ibatis.type.LocalDateTimeTypeHandler} AND #{createTime[1],typeHandler=org.apache.ibatis.type.LocalDateTimeTypeHandler}
+        <if test="deptIds != null and deptIds.size &gt; 0">
+            AND a.dept_id IN
+            <foreach collection="deptIds" index="index" item="key" open="(" separator="," close=")">
+                #{key}
+            </foreach>
+        </if>
     </select>
 
     <select id="rhList"

+ 3 - 1
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/dept/DeptServiceImpl.java

@@ -252,7 +252,9 @@ public class DeptServiceImpl implements DeptService {
 
     @Override
     public List<DeptDO> getDeptByName(String deptName) {
-        return deptMapper.selectList("name", deptName);
+        DeptListReqVO reqVO = new DeptListReqVO();
+        reqVO.setName(deptName);
+        return deptMapper.selectList(reqVO);
     }
 
     @Override