Quellcode durchsuchen

refactor(更新)
- 增加已上锁点位的获取

周文健 vor 4 Monaten
Ursprung
Commit
211b9a03d6

+ 35 - 17
data/src/main/java/com/grkj/data/dao/JobTicketDao.kt

@@ -242,12 +242,7 @@ interface JobTicketDao {
      * 根据作业id获取作业点位详细数据
      */
     @Query(
-        "select istp.*, " +
-                "iip.point_name as pointName," +
-                "iip.remark as pointFunction " +
-                "from is_job_ticket_points istp " +
-                "left join is_isolation_point iip on istp.point_id = iip.point_id " +
-                "where ticket_id = :ticketId"
+        "select istp.*, " + "iip.point_name as pointName," + "iip.remark as pointFunction " + "from is_job_ticket_points istp " + "left join is_isolation_point iip on istp.point_id = iip.point_id " + "where ticket_id = :ticketId"
     )
     fun getJobTicketPointsDataByTicketId(ticketId: Long): List<IsJobTicketPointsDataVo>
 
@@ -290,8 +285,7 @@ interface JobTicketDao {
      */
     @Query("update is_job_ticket_step set step_status = :status,update_time = :updateTime where step_id = :stepId")
     fun updateTicketStepStatus(
-        stepId: Long,
-        status: String, updateTime: String = TimeUtils.nowString(
+        stepId: Long, status: String, updateTime: String = TimeUtils.nowString(
             TimeUtils.DEFAULT_DATE_HOUR_MIN_SEC_FORMAT
         )
     )
@@ -310,9 +304,7 @@ interface JobTicketDao {
      * 获取工作中的作业数量
      */
     @Query(
-        "select count(1) from is_job_ticket where ticket_status in ('1','2','3','4') " +
-                "AND (:workstationId IS NULL OR trim(:workstationId) = '' OR workstation_id = :workstationId) " +
-                "AND (:modeId IS NULL OR trim(:modeId) = '' OR mode_id = :modeId) "
+        "select count(1) from is_job_ticket where ticket_status in ('1','2','3','4') " + "AND (:workstationId IS NULL OR trim(:workstationId) = '' OR workstation_id = :workstationId) " + "AND (:modeId IS NULL OR trim(:modeId) = '' OR mode_id = :modeId) "
     )
     fun getInProgressJobSize(workstationId: Long?, modeId: Long?): Int
 
@@ -328,9 +320,7 @@ interface JobTicketDao {
      * 获取所有作业数量
      */
     @Query(
-        "select count(1) from is_job_ticket where (:workstationId IS NULL OR trim(:workstationId) = '' OR workstation_id = :workstationId) " +
-                "AND (:startTime IS NULL OR trim(:startTime) = '' OR (create_time >= :startTime OR update_time >= :startTime)) " +
-                "AND (:endTime IS NULL OR trim(:endTime) = '' OR (create_time <= :endTime OR update_time <= :endTime)) "
+        "select count(1) from is_job_ticket where (:workstationId IS NULL OR trim(:workstationId) = '' OR workstation_id = :workstationId) " + "AND (:startTime IS NULL OR trim(:startTime) = '' OR (create_time >= :startTime OR update_time >= :startTime)) " + "AND (:endTime IS NULL OR trim(:endTime) = '' OR (create_time <= :endTime OR update_time <= :endTime)) "
     )
     fun getAllJobSize(workstationId: Long?, startTime: String?, endTime: String?): Int
 
@@ -431,9 +421,7 @@ interface JobTicketDao {
     """
     )
     fun getVirtualLockConflictPoint(
-        pointId: Long?,
-        lockId: Long?,
-        ticketId: Long
+        pointId: Long?, lockId: Long?, ticketId: Long
     ): List<IsJobTicketPoints>
 
     /**
@@ -465,4 +453,34 @@ interface JobTicketDao {
      */
     @Update
     fun updateTicketData(ticket: IsJobTicket)
+
+    /**
+     * 获取所有上锁点位不包括异常作业
+     */
+    @Query(
+        """
+        select ijtp.* from is_job_ticket_points ijtp 
+        left join is_job_ticket ijt on ijtp.ticket_id = ijt.ticket_id
+        where ijtp.point_status = "1" 
+        and ijt.ticket_status = 5
+        and ijt.ex_status is null
+        and ijtp.point_id in (:workstationPointIds)
+    """
+    )
+    fun getAllLockedPointDataWithoutExceptionJob(workstationPointIds: List<Long>): List<IsJobTicketPoints>
+
+    /**
+     * 获取所有异常作业上锁点位
+     */
+    @Query(
+        """
+        select ijtp.* from is_job_ticket_points ijtp 
+        left join is_job_ticket ijt on ijtp.ticket_id = ijt.ticket_id
+        where ijtp.point_status = "1" 
+        and ijt.ex_status is not null 
+        and ijtp.point_id in (:workstationPointIds)
+    """
+    )
+    fun getAllLockedPointDataWithExceptionJob(workstationPointIds: List<Long>): List<IsJobTicketPoints>
+
 }

+ 3 - 0
data/src/main/java/com/grkj/data/model/vo/PointManageVo.kt

@@ -15,6 +15,9 @@ class PointManageVo {
     var workstationId: Long? = 0
     var powerType: String? = ""
 
+    @Ignore
+    var lockId: Long = 0
+
     @Ignore
     var isSelected: Boolean = false
 }

+ 5 - 0
data/src/main/java/com/grkj/data/repository/IIsolationPointRepository.kt

@@ -38,4 +38,9 @@ interface IIsolationPointRepository {
      */
     fun getAllPointManageDataWithWorkstationId(workstationId: Long): MutableList<PointManageVo>
 
+    /**
+     * 获取所有上锁隔离点数据
+     */
+    fun getAllLockedPointManageDataWithWorkstationId(workstationId: Long): MutableList<PointManageVo>
+
 }

+ 4 - 0
data/src/main/java/com/grkj/data/repository/impl/network/NetworkIsolationPointRepository.kt

@@ -37,4 +37,8 @@ class NetworkIsolationPointRepository  @Inject constructor() : BaseRepository(),
     override fun getAllPointManageDataWithWorkstationId(workstationId: Long): MutableList<PointManageVo> {
         TODO("Not yet implemented")
     }
+
+    override fun getAllLockedPointManageDataWithWorkstationId(workstationId: Long): MutableList<PointManageVo> {
+        TODO("Not yet implemented")
+    }
 }

+ 14 - 1
data/src/main/java/com/grkj/data/repository/impl/standard/IsolationPointRepository.kt

@@ -1,6 +1,7 @@
 package com.grkj.data.repository.impl.standard
 
 import com.grkj.data.dao.IsolationPointDao
+import com.grkj.data.dao.JobTicketDao
 import com.grkj.data.model.dos.IsIsolationPoint
 import com.grkj.data.model.vo.AddPointManageVo
 import com.grkj.data.model.vo.PointManageFilterVo
@@ -15,7 +16,10 @@ import javax.inject.Singleton
  * 隔离点仓储实现
  */
 @Singleton
-class IsolationPointRepository @Inject constructor(val isolationPointDao: IsolationPointDao) :
+class IsolationPointRepository @Inject constructor(
+    val isolationPointDao: IsolationPointDao,
+    val jobTicketDao: JobTicketDao
+) :
     BaseRepository(), IIsolationPointRepository {
 
     override fun deletePointByPointIds(pointIds: List<Long>) {
@@ -62,4 +66,13 @@ class IsolationPointRepository @Inject constructor(val isolationPointDao: Isolat
     override fun getAllPointManageDataWithWorkstationId(workstationId: Long): MutableList<PointManageVo> {
         return isolationPointDao.getAllPointManageDataWithWorkstationId(workstationId)
     }
+
+    override fun getAllLockedPointManageDataWithWorkstationId(workstationId: Long): MutableList<PointManageVo> {
+        val allPointManageData =
+            isolationPointDao.getAllPointManageDataWithWorkstationId(workstationId)
+        val allLockedPointData =
+            jobTicketDao.getAllLockedPointDataWithoutExceptionJob(allPointManageData.map { it.pointId })
+        return allPointManageData.filter { it.pointId in allLockedPointData.map { it.pointId } }
+            .toMutableList()
+    }
 }