Browse Source

修改mybatis逻辑删除查询条件

小车车 3 months ago
parent
commit
2c08b2cbb7
22 changed files with 52 additions and 26 deletions
  1. 1 1
      yudao-module-iscs/src/main/java/cn/iocoder/yudao/module/iscs/service/rfidtoken/RfidTokenServiceImpl.java
  2. 1 1
      yudao-module-iscs/src/main/resources/mapper/ExceptionMapper.xml
  3. 1 0
      yudao-module-iscs/src/main/resources/mapper/ExceptionMisplaceMapper.xml
  4. 2 0
      yudao-module-iscs/src/main/resources/mapper/IsolationPointMapper.xml
  5. 3 1
      yudao-module-iscs/src/main/resources/mapper/JobTicketMapper.xml
  6. 1 1
      yudao-module-iscs/src/main/resources/mapper/JobTicketPointsMapper.xml
  7. 1 1
      yudao-module-iscs/src/main/resources/mapper/JobTicketUserMapper.xml
  8. 1 0
      yudao-module-iscs/src/main/resources/mapper/KeyMapper.xml
  9. 1 0
      yudao-module-iscs/src/main/resources/mapper/LockCabinetMapper.xml
  10. 1 0
      yudao-module-iscs/src/main/resources/mapper/LockMapper.xml
  11. 1 0
      yudao-module-iscs/src/main/resources/mapper/LocksetMapper.xml
  12. 1 0
      yudao-module-iscs/src/main/resources/mapper/MaterialsChangeRecordMapper.xml
  13. 1 0
      yudao-module-iscs/src/main/resources/mapper/MaterialsCheckPlanMapper.xml
  14. 1 0
      yudao-module-iscs/src/main/resources/mapper/MaterialsCheckRecordMapper.xml
  15. 1 0
      yudao-module-iscs/src/main/resources/mapper/MaterialsLoanMapper.xml
  16. 1 0
      yudao-module-iscs/src/main/resources/mapper/MaterialsMapper.xml
  17. 1 0
      yudao-module-iscs/src/main/resources/mapper/MaterialsPropertyValueMapper.xml
  18. 1 1
      yudao-module-iscs/src/main/resources/mapper/NotifyConfigDetailMapper.xml
  19. 2 1
      yudao-module-iscs/src/main/resources/mapper/NotifyConfigMapper.xml
  20. 2 1
      yudao-module-iscs/src/main/resources/mapper/SopExecutionPlanMapper.xml
  21. 2 1
      yudao-module-iscs/src/main/resources/mapper/SopMapper.xml
  22. 25 17
      yudao-module-iscs/src/main/resources/mapper/StatisticsMapper.xml

+ 1 - 1
yudao-module-iscs/src/main/java/cn/iocoder/yudao/module/iscs/service/rfidtoken/RfidTokenServiceImpl.java

@@ -76,7 +76,7 @@ public class RfidTokenServiceImpl extends ServiceImpl<RfidTokenMapper, RfidToken
         public void deleteRfidTokenListByIds(List<Long> ids) {
         public void deleteRfidTokenListByIds(List<Long> ids) {
         // 查询有没有正在使用的点位,如果有则不能删除
         // 查询有没有正在使用的点位,如果有则不能删除
         List<IsolationPointDO> list = isolationPointService.list(Wrappers.<IsolationPointDO>lambdaQuery()
         List<IsolationPointDO> list = isolationPointService.list(Wrappers.<IsolationPointDO>lambdaQuery()
-                .in(IsolationPointDO::getId, ids));
+                .in(IsolationPointDO::getRfidId, ids));
         Assert.isTrue(list.isEmpty(), "存在正在被隔离点使用的RFID,不可删除!");
         Assert.isTrue(list.isEmpty(), "存在正在被隔离点使用的RFID,不可删除!");
         // 校验存在
         // 校验存在
         validateRfidTokenExists(ids);
         validateRfidTokenExists(ids);

+ 1 - 1
yudao-module-iscs/src/main/resources/mapper/ExceptionMapper.xml

@@ -26,7 +26,7 @@
                 LEFT JOIN system_dict_data dd ON e.exception_type = dd.value AND dd.dict_type = 'type_of_exception'
                 LEFT JOIN system_dict_data dd ON e.exception_type = dd.value AND dd.dict_type = 'type_of_exception'
                 LEFT JOIN system_dict_data ddd ON e.exception_level = ddd.value AND ddd.dict_type = 'severity_level'
                 LEFT JOIN system_dict_data ddd ON e.exception_level = ddd.value AND ddd.dict_type = 'severity_level'
                 LEFT JOIN system_users u ON u.id = e.raiser
                 LEFT JOIN system_users u ON u.id = e.raiser
-        where e.id = #{id}
+        where e.deleted = 0 and e.id = #{id}
     </select>
     </select>
     <select id="getExceptionPage"
     <select id="getExceptionPage"
             resultType="cn.iocoder.yudao.module.iscs.controller.admin.exception.vo.ExceptionRespVO">
             resultType="cn.iocoder.yudao.module.iscs.controller.admin.exception.vo.ExceptionRespVO">

+ 1 - 0
yudao-module-iscs/src/main/resources/mapper/ExceptionMisplaceMapper.xml

@@ -24,6 +24,7 @@
         LEFT JOIN isc_materials_cabinet c2 ON c2.id = e.restitution_to_id
         LEFT JOIN isc_materials_cabinet c2 ON c2.id = e.restitution_to_id
         LEFT JOIN system_users u ON u.id = e.restitution_user_id
         LEFT JOIN system_users u ON u.id = e.restitution_user_id
         <where>
         <where>
+            e.deleted = 0
             <if test="vo.materialsName != null and vo.materialsName.trim != ''">
             <if test="vo.materialsName != null and vo.materialsName.trim != ''">
                 and m.materials_name like concat('%',#{vo.materialsName},'%')
                 and m.materials_name like concat('%',#{vo.materialsName},'%')
             </if>
             </if>

+ 2 - 0
yudao-module-iscs/src/main/resources/mapper/IsolationPointMapper.xml

@@ -20,6 +20,7 @@
         left join system_dict_data dd on dd.dict_type = 'point_type' and p.point_type = dd.value
         left join system_dict_data dd on dd.dict_type = 'point_type' and p.point_type = dd.value
         left join isc_rfid_token r on r.id = p.rfid_id
         left join isc_rfid_token r on r.id = p.rfid_id
         <where>
         <where>
+            p.deleted = 0 and
             p.id in
             p.id in
             <foreach collection="pointIds" index="index" item="item" open="(" separator="," close=")">
             <foreach collection="pointIds" index="index" item="item" open="(" separator="," close=")">
                 #{item}
                 #{item}
@@ -48,6 +49,7 @@
         LEFT JOIN isc_machinery ma ON ma.id = m.machinery_id
         LEFT JOIN isc_machinery ma ON ma.id = m.machinery_id
         LEFT JOIN isc_rfid_token r on r.id = p.rfid_id
         LEFT JOIN isc_rfid_token r on r.id = p.rfid_id
         <where>
         <where>
+            p.deleted = 0
             <if test="vo.pointCode != null and vo.pointCode.trim != ''">
             <if test="vo.pointCode != null and vo.pointCode.trim != ''">
                 and p.point_code like concat('%',#{vo.pointCode},'%')
                 and p.point_code like concat('%',#{vo.pointCode},'%')
             </if>
             </if>

+ 3 - 1
yudao-module-iscs/src/main/resources/mapper/JobTicketMapper.xml

@@ -25,6 +25,7 @@
             LEFT JOIN is_job_ticket_user u ON u.ticket_id = j.id
             LEFT JOIN is_job_ticket_user u ON u.ticket_id = j.id
         </if>
         </if>
         <where>
         <where>
+            j.deleted = 0
             <if test="vo.ticketCode != null and vo.ticketCode.trim != ''">
             <if test="vo.ticketCode != null and vo.ticketCode.trim != ''">
                 and j.ticket_code like concat('%',#{vo.ticketCode},'%')
                 and j.ticket_code like concat('%',#{vo.ticketCode},'%')
             </if>
             </if>
@@ -71,6 +72,7 @@
         left join isc_workstation w on w.id = j.workstation_id
         left join isc_workstation w on w.id = j.workstation_id
         left join isc_machinery m ON m.id = j.machinery_id
         left join isc_machinery m ON m.id = j.machinery_id
         <where>
         <where>
+            j.deleted = 0 and
             (j.ticket_status &lt; 5 OR ( j.ticket_end_time > CURDATE() AND j.ticket_status = 5 ))
             (j.ticket_status &lt; 5 OR ( j.ticket_end_time > CURDATE() AND j.ticket_status = 5 ))
             <if test="vo.ticketCode != null and vo.ticketCode.trim != ''">
             <if test="vo.ticketCode != null and vo.ticketCode.trim != ''">
                 and j.ticket_code like concat('%',#{vo.ticketCode},'%')
                 and j.ticket_code like concat('%',#{vo.ticketCode},'%')
@@ -111,6 +113,6 @@
                 left join isc_workstation w on w.id = j.workstation_id
                 left join isc_workstation w on w.id = j.workstation_id
                 left join isc_machinery m ON m.id = j.machinery_id
                 left join isc_machinery m ON m.id = j.machinery_id
                 left join isc_sop s ON s.id = j.sop_id
                 left join isc_sop s ON s.id = j.sop_id
-        where j.id = #{id}
+        where p.deleted = 0 and j.id = #{id}
     </select>
     </select>
 </mapper>
 </mapper>

+ 1 - 1
yudao-module-iscs/src/main/resources/mapper/JobTicketPointsMapper.xml

@@ -20,6 +20,6 @@
             isc_job_ticket_points tp
             isc_job_ticket_points tp
                 LEFT JOIN isc_isolation_point p ON p.id = tp.point_id
                 LEFT JOIN isc_isolation_point p ON p.id = tp.point_id
                 LEFT JOIN system_users s ON s.id = tp.lock_user_id
                 LEFT JOIN system_users s ON s.id = tp.lock_user_id
-        where tp.ticket_id = #{ticketId}
+        where tp.deleted = 0 and tp.ticket_id = #{ticketId}
     </select>
     </select>
 </mapper>
 </mapper>

+ 1 - 1
yudao-module-iscs/src/main/resources/mapper/JobTicketUserMapper.xml

@@ -17,6 +17,6 @@
         FROM
         FROM
             isc_job_ticket_user tu
             isc_job_ticket_user tu
                 LEFT JOIN system_users u ON tu.user_id = u.id
                 LEFT JOIN system_users u ON tu.user_id = u.id
-        where tu.ticket_id = #{ticketId}
+        where tu.deleted = 0 and tu.ticket_id = #{ticketId}
     </select>
     </select>
 </mapper>
 </mapper>

+ 1 - 0
yudao-module-iscs/src/main/resources/mapper/KeyMapper.xml

@@ -17,6 +17,7 @@
         isc_key k
         isc_key k
         LEFT JOIN isc_hardware h ON k.hardware_id = h.id
         LEFT JOIN isc_hardware h ON k.hardware_id = h.id
         <where>
         <where>
+            k.deleted = 0
             <if test="vo.keyCode != null and vo.keyCode.trim != ''">
             <if test="vo.keyCode != null and vo.keyCode.trim != ''">
                 and k.key_code like concat('%',#{vo.keyCode},'%')
                 and k.key_code like concat('%',#{vo.keyCode},'%')
             </if>
             </if>

+ 1 - 0
yudao-module-iscs/src/main/resources/mapper/LockCabinetMapper.xml

@@ -20,6 +20,7 @@
         LEFT JOIN isc_hardware h ON h.id = c.hardware_id
         LEFT JOIN isc_hardware h ON h.id = c.hardware_id
         LEFT JOIN isc_workstation w ON w.id = c.workstation_id
         LEFT JOIN isc_workstation w ON w.id = c.workstation_id
         <where>
         <where>
+            c.deleted = 0
             <if test="vo.cabinetName != null and vo.cabinetName != ''">
             <if test="vo.cabinetName != null and vo.cabinetName != ''">
                 AND c.cabinet_name like concat('%', #{vo.cabinetName}, '%')
                 AND c.cabinet_name like concat('%', #{vo.cabinetName}, '%')
             </if>
             </if>

+ 1 - 0
yudao-module-iscs/src/main/resources/mapper/LockMapper.xml

@@ -19,6 +19,7 @@
         LEFT JOIN isc_lock_type lt ON l.lock_type_id = lt.id
         LEFT JOIN isc_lock_type lt ON l.lock_type_id = lt.id
         LEFT JOIN isc_hardware h ON l.hardware_id = h.id
         LEFT JOIN isc_hardware h ON l.hardware_id = h.id
         <where>
         <where>
+            l.deleted = 0
             <if test="vo.lockCode != null and vo.lockCode.trim != ''">
             <if test="vo.lockCode != null and vo.lockCode.trim != ''">
                 and l.lock_code like concat('%',#{vo.lockCode},'%')
                 and l.lock_code like concat('%',#{vo.lockCode},'%')
             </if>
             </if>

+ 1 - 0
yudao-module-iscs/src/main/resources/mapper/LocksetMapper.xml

@@ -20,6 +20,7 @@
         LEFT JOIN isc_lockset_type lt ON l.lockset_type_id = lt.id
         LEFT JOIN isc_lockset_type lt ON l.lockset_type_id = lt.id
         LEFT JOIN isc_materials m ON l.materials_id = m.id
         LEFT JOIN isc_materials m ON l.materials_id = m.id
         <where>
         <where>
+            l.deleted = 0
             <if test="vo.locksetCode != null and vo.locksetCode.trim != ''">
             <if test="vo.locksetCode != null and vo.locksetCode.trim != ''">
                 and l.lockset_code like concat('%',#{vo.locksetCode},'%')
                 and l.lockset_code like concat('%',#{vo.locksetCode},'%')
             </if>
             </if>

+ 1 - 0
yudao-module-iscs/src/main/resources/mapper/MaterialsChangeRecordMapper.xml

@@ -29,6 +29,7 @@
         LEFT JOIN isc_materials_type t ON t.id = m.materials_type_id
         LEFT JOIN isc_materials_type t ON t.id = m.materials_type_id
         LEFT JOIN system_users u ON u.id = c.change_user_id
         LEFT JOIN system_users u ON u.id = c.change_user_id
         <where>
         <where>
+            c.deleted = 0
             <if test="vo.recordId != null">
             <if test="vo.recordId != null">
                 and c.check_record_id = #{vo.recordId}
                 and c.check_record_id = #{vo.recordId}
             </if>
             </if>

+ 1 - 0
yudao-module-iscs/src/main/resources/mapper/MaterialsCheckPlanMapper.xml

@@ -18,6 +18,7 @@
         LEFT JOIN isc_materials_plan_cabinet c ON c.plan_id = p.id
         LEFT JOIN isc_materials_plan_cabinet c ON c.plan_id = p.id
         LEFT JOIN system_users u ON u.id = p.check_user_id
         LEFT JOIN system_users u ON u.id = p.check_user_id
         <where>
         <where>
+            p.deleted = 0
             <if test="vo.cabinetId != null">
             <if test="vo.cabinetId != null">
                 and c.cabinet_id = #{vo.cabinetId}
                 and c.cabinet_id = #{vo.cabinetId}
             </if>
             </if>

+ 1 - 0
yudao-module-iscs/src/main/resources/mapper/MaterialsCheckRecordMapper.xml

@@ -29,6 +29,7 @@
         LEFT JOIN isc_materials_type t ON t.id = m.materials_type_id
         LEFT JOIN isc_materials_type t ON t.id = m.materials_type_id
         LEFT JOIN system_users u ON u.id = r.check_user_id
         LEFT JOIN system_users u ON u.id = r.check_user_id
         <where>
         <where>
+            r.deleted = 0
             <if test="vo.planId != null">
             <if test="vo.planId != null">
                 and r.plan_id = #{vo.planId}
                 and r.plan_id = #{vo.planId}
             </if>
             </if>

+ 1 - 0
yudao-module-iscs/src/main/resources/mapper/MaterialsLoanMapper.xml

@@ -44,6 +44,7 @@
         LEFT JOIN system_users u1 ON u1.id = l.restitution_user_id
         LEFT JOIN system_users u1 ON u1.id = l.restitution_user_id
         LEFT JOIN isc_materials_type mt ON mt.id = m.materials_type_id
         LEFT JOIN isc_materials_type mt ON mt.id = m.materials_type_id
         <where>
         <where>
+            l.deleted = 0
             <if test="vo.materialsName != null and vo.materialsName.trim != ''">
             <if test="vo.materialsName != null and vo.materialsName.trim != ''">
                 and m.materials_name like concat('%',#{vo.materialsName},'%')
                 and m.materials_name like concat('%',#{vo.materialsName},'%')
             </if>
             </if>

+ 1 - 0
yudao-module-iscs/src/main/resources/mapper/MaterialsMapper.xml

@@ -84,6 +84,7 @@
         LEFT JOIN isc_materials_type t ON t.id = m.materials_type_id
         LEFT JOIN isc_materials_type t ON t.id = m.materials_type_id
         LEFT JOIN isc_materials_cabinet c ON c.id = m.materials_cabinet_id
         LEFT JOIN isc_materials_cabinet c ON c.id = m.materials_cabinet_id
         <where>
         <where>
+            m.deleted = 0 and
             m.materials_id in
             m.materials_id in
             <foreach collection="materialsIds" index="index" item="item" open="(" separator="," close=")">
             <foreach collection="materialsIds" index="index" item="item" open="(" separator="," close=")">
                 #{item}
                 #{item}

+ 1 - 0
yudao-module-iscs/src/main/resources/mapper/MaterialsPropertyValueMapper.xml

@@ -14,6 +14,7 @@
         select v.*, p.property_name from isc_materials_property_value v
         select v.*, p.property_name from isc_materials_property_value v
         left join isc_materials_property p on v.property_id = p.id
         left join isc_materials_property p on v.property_id = p.id
         <where>
         <where>
+            v.deleted = 0
             <if test="vo.valueName != null and vo.valueName.trim != ''">
             <if test="vo.valueName != null and vo.valueName.trim != ''">
                 and v.value_name like concat('%',#{vo.valueName},'%')
                 and v.value_name like concat('%',#{vo.valueName},'%')
             </if>
             </if>

+ 1 - 1
yudao-module-iscs/src/main/resources/mapper/NotifyConfigDetailMapper.xml

@@ -15,6 +15,6 @@
         from isc_notify_config_detail d
         from isc_notify_config_detail d
             left join system_notify_template t on t.code = d.notify_template_code
             left join system_notify_template t on t.code = d.notify_template_code
             left join system_role r on r.id = d.role_id
             left join system_role r on r.id = d.role_id
-        where d.config_id = #{configId}
+        where d.deleted = 0 and d.config_id = #{configId}
     </select>
     </select>
 </mapper>
 </mapper>

+ 2 - 1
yudao-module-iscs/src/main/resources/mapper/NotifyConfigMapper.xml

@@ -20,8 +20,9 @@
         LEFT JOIN isc_workstation w ON w.id = n.workstation_id
         LEFT JOIN isc_workstation w ON w.id = n.workstation_id
         LEFT JOIN isc_sop_workflow_step ws ON ws.id = n.rule and n.type = 3
         LEFT JOIN isc_sop_workflow_step ws ON ws.id = n.rule and n.type = 3
         <where>
         <where>
+            n.deleted = 0
             <if test="vo.sopId != null">
             <if test="vo.sopId != null">
-                n.sop_id = #{vo.sopId}
+                and n.sop_id = #{vo.sopId}
             </if>
             </if>
         </where>
         </where>
     </select>
     </select>

+ 2 - 1
yudao-module-iscs/src/main/resources/mapper/SopExecutionPlanMapper.xml

@@ -18,8 +18,9 @@
             isc_sop_execution_plan e
             isc_sop_execution_plan e
                 LEFT JOIN isc_sop s ON s.id = e.sop_id
                 LEFT JOIN isc_sop s ON s.id = e.sop_id
         <where>
         <where>
+            e.deleted = 0
             <if test="vo.nextExecutDate != null and vo.nextExecutDate.trim != ''">
             <if test="vo.nextExecutDate != null and vo.nextExecutDate.trim != ''">
-                e.next_execut_date = #{vo.nextExecutDate}
+                and e.next_execut_date = #{vo.nextExecutDate}
             </if>
             </if>
         </where>
         </where>
     </select>
     </select>

+ 2 - 1
yudao-module-iscs/src/main/resources/mapper/SopMapper.xml

@@ -26,6 +26,7 @@
         LEFT JOIN isc_sop_points p ON p.sop_id = s.id
         LEFT JOIN isc_sop_points p ON p.sop_id = s.id
         LEFT JOIN system_dict_data di ON di.dict_type = "sop_type" and di.value = s.sop_type
         LEFT JOIN system_dict_data di ON di.dict_type = "sop_type" and di.value = s.sop_type
         <where>
         <where>
+            s.deleted = 0
             <if test="vo.sopCode != null and vo.sopCode.trim != ''">
             <if test="vo.sopCode != null and vo.sopCode.trim != ''">
                 and s.sop_code like concat('%',#{vo.sopCode},'%')
                 and s.sop_code like concat('%',#{vo.sopCode},'%')
             </if>
             </if>
@@ -76,6 +77,6 @@
                 LEFT JOIN isc_machinery d ON d.id = s.machinery_id
                 LEFT JOIN isc_machinery d ON d.id = s.machinery_id
                 LEFT JOIN isc_sop_points p ON p.sop_id = s.id
                 LEFT JOIN isc_sop_points p ON p.sop_id = s.id
                 LEFT JOIN system_dict_data di ON di.dict_type = "sop_type" and di.value = s.sop_type
                 LEFT JOIN system_dict_data di ON di.dict_type = "sop_type" and di.value = s.sop_type
-        where s.id = #{id}
+        where s.deleted = 0 and s.id = #{id}
     </select>
     </select>
 </mapper>
 </mapper>

+ 25 - 17
yudao-module-iscs/src/main/resources/mapper/StatisticsMapper.xml

@@ -17,6 +17,7 @@
                 LEFT JOIN isc_workstation w ON w.id = c.workstation_id
                 LEFT JOIN isc_workstation w ON w.id = c.workstation_id
                 LEFT JOIN ( SELECT o.cabinet_id, count( o.id ) AS open_count FROM isc_cabinet_open_record o
                 LEFT JOIN ( SELECT o.cabinet_id, count( o.id ) AS open_count FROM isc_cabinet_open_record o
                 <where>
                 <where>
+                    c.deleted = 0
                     <if test="startTime != null and startTime.trim != ''">
                     <if test="startTime != null and startTime.trim != ''">
                         and o.open_time &gt;= #{startTime}
                         and o.open_time &gt;= #{startTime}
                     </if>
                     </if>
@@ -60,10 +61,11 @@
         ( CASE WHEN d.bad_count IS NULL THEN 0 ELSE d.bad_count END ) AS bad_count
         ( CASE WHEN d.bad_count IS NULL THEN 0 ELSE d.bad_count END ) AS bad_count
         FROM
         FROM
         isc_materials_type t
         isc_materials_type t
-        LEFT JOIN ( SELECT m.materials_type_id, count( m.id ) AS all_count FROM isc_materials m WHERE m.materials_cabinet_id is not null GROUP BY m.materials_type_id ) a ON a.materials_type_id = t.id
-        LEFT JOIN (SELECT m.materials_type_id, count( m.id ) AS will_expire_count FROM isc_materials m WHERE m.materials_cabinet_id is not null and DATE_ADD( NOW(), INTERVAL 30 DAY ) &gt; m.expiration_date AND NOW() &lt; m.expiration_date GROUP BY m.materials_type_id) b ON b.materials_type_id = t.id
-        LEFT JOIN (SELECT m.materials_type_id, count( m.id ) AS expired_count FROM isc_materials m WHERE m.materials_cabinet_id is not null and m.STATUS = '2' GROUP BY m.materials_type_id ) c ON c.materials_type_id = t.id
-        LEFT JOIN (SELECT m.materials_type_id, count( m.id ) AS bad_count FROM isc_materials m WHERE m.materials_cabinet_id is not null and m.STATUS = '1' GROUP BY m.materials_type_id) d ON d.materials_type_id = t.id
+        LEFT JOIN ( SELECT m.materials_type_id, count( m.id ) AS all_count FROM isc_materials m WHERE m.deleted = 0 and m.materials_cabinet_id is not null GROUP BY m.materials_type_id ) a ON a.materials_type_id = t.id
+        LEFT JOIN (SELECT m.materials_type_id, count( m.id ) AS will_expire_count FROM isc_materials m WHERE m.deleted = 0 and m.materials_cabinet_id is not null and DATE_ADD( NOW(), INTERVAL 30 DAY ) &gt; m.expiration_date AND NOW() &lt; m.expiration_date GROUP BY m.materials_type_id) b ON b.materials_type_id = t.id
+        LEFT JOIN (SELECT m.materials_type_id, count( m.id ) AS expired_count FROM isc_materials m WHERE m.deleted = 0 and m.materials_cabinet_id is not null and m.STATUS = '2' GROUP BY m.materials_type_id ) c ON c.materials_type_id = t.id
+        LEFT JOIN (SELECT m.materials_type_id, count( m.id ) AS bad_count FROM isc_materials m WHERE m.deleted = 0 and m.materials_cabinet_id is not null and m.STATUS = '1' GROUP BY m.materials_type_id) d ON d.materials_type_id = t.id
+        where t.deleted = 0
         order by t.id asc
         order by t.id asc
     </select>
     </select>
 
 
@@ -82,6 +84,7 @@
         LEFT JOIN ( SELECT ma.materials_type_id, count( m.materials_id ) AS all_count FROM
         LEFT JOIN ( SELECT ma.materials_type_id, count( m.materials_id ) AS all_count FROM
         isc_materials_loan m LEFT JOIN isc_materials ma on ma.id = m.materials_id
         isc_materials_loan m LEFT JOIN isc_materials ma on ma.id = m.materials_id
         <where>
         <where>
+            m.deleted = 0
             <if test="startTime != null and startTime.trim != ''">
             <if test="startTime != null and startTime.trim != ''">
                 and m.create_time &gt;= #{startTime}
                 and m.create_time &gt;= #{startTime}
             </if>
             </if>
@@ -94,7 +97,7 @@
         LEFT JOIN ( SELECT ma.materials_type_id, count( m.materials_id ) AS return_count FROM
         LEFT JOIN ( SELECT ma.materials_type_id, count( m.materials_id ) AS return_count FROM
         isc_materials_loan m LEFT JOIN isc_materials ma on ma.id = m.materials_id
         isc_materials_loan m LEFT JOIN isc_materials ma on ma.id = m.materials_id
         <where>
         <where>
-            m.actual_restitution_time &lt;= m.reminder_time
+            m.deleted = 0 and m.actual_restitution_time &lt;= m.reminder_time
             <if test="startTime != null and startTime.trim != ''">
             <if test="startTime != null and startTime.trim != ''">
                 and m.create_time &gt;= #{startTime}
                 and m.create_time &gt;= #{startTime}
             </if>
             </if>
@@ -107,7 +110,7 @@
         LEFT JOIN ( SELECT ma.materials_type_id, count( m.materials_id ) AS timeout_count FROM
         LEFT JOIN ( SELECT ma.materials_type_id, count( m.materials_id ) AS timeout_count FROM
         isc_materials_loan m LEFT JOIN isc_materials ma on ma.id = m.materials_id
         isc_materials_loan m LEFT JOIN isc_materials ma on ma.id = m.materials_id
         <where>
         <where>
-            m.actual_restitution_time &gt; m.reminder_time
+            m.deleted = 0 and m.actual_restitution_time &gt; m.reminder_time
             <if test="startTime != null and startTime.trim != ''">
             <if test="startTime != null and startTime.trim != ''">
                 and m.create_time &gt;= #{startTime}
                 and m.create_time &gt;= #{startTime}
             </if>
             </if>
@@ -120,6 +123,7 @@
         LEFT JOIN ( SELECT ma.materials_type_id, AVG(TIMESTAMPDIFF(SECOND, m.loan_time, m.actual_restitution_time)) AS average_time FROM
         LEFT JOIN ( SELECT ma.materials_type_id, AVG(TIMESTAMPDIFF(SECOND, m.loan_time, m.actual_restitution_time)) AS average_time FROM
         isc_materials_loan m LEFT JOIN isc_materials ma on ma.id = m.materials_id
         isc_materials_loan m LEFT JOIN isc_materials ma on ma.id = m.materials_id
         <where>
         <where>
+            m.deleted = 0
             <if test="startTime != null and startTime.trim != ''">
             <if test="startTime != null and startTime.trim != ''">
                 and m.create_time &gt;= #{startTime}
                 and m.create_time &gt;= #{startTime}
             </if>
             </if>
@@ -128,6 +132,7 @@
             </if>
             </if>
         </where>
         </where>
         GROUP BY ma.materials_type_id ) d ON d.materials_type_id = t.id
         GROUP BY ma.materials_type_id ) d ON d.materials_type_id = t.id
+        where t.deleted = 0
         order by t.id asc
         order by t.id asc
     </select>
     </select>
     <select id="getMaterialsChangeStatistics"
     <select id="getMaterialsChangeStatistics"
@@ -144,7 +149,7 @@
                 isc_materials_change_record m
                 isc_materials_change_record m
                 LEFT JOIN isc_materials ma on ma.id = m.old_materials_id
                 LEFT JOIN isc_materials ma on ma.id = m.old_materials_id
                 <where>
                 <where>
-                    (m.check_record_id = null or m.check_record_id = 0)
+                    m.deleted = 0 and (m.check_record_id = null or m.check_record_id = 0)
                     <if test="startTime != null and startTime.trim != ''">
                     <if test="startTime != null and startTime.trim != ''">
                         and m.create_time &gt;= #{startTime}
                         and m.create_time &gt;= #{startTime}
                     </if>
                     </if>
@@ -160,7 +165,7 @@
                     LEFT JOIN isc_materials ma on ma.id = m.old_materials_id
                     LEFT JOIN isc_materials ma on ma.id = m.old_materials_id
                     LEFT JOIN isc_materials_check_record mc on mc.id = m.check_record_id
                     LEFT JOIN isc_materials_check_record mc on mc.id = m.check_record_id
                     <where>
                     <where>
-                        mc.reason = '2'
+                        m.deleted = 0 and mc.reason = '2'
                         <if test="startTime != null and startTime.trim != ''">
                         <if test="startTime != null and startTime.trim != ''">
                             and m.create_time &gt;= #{startTime}
                             and m.create_time &gt;= #{startTime}
                         </if>
                         </if>
@@ -176,7 +181,7 @@
                         LEFT JOIN isc_materials ma on ma.id = m.old_materials_id
                         LEFT JOIN isc_materials ma on ma.id = m.old_materials_id
                         LEFT JOIN isc_materials_check_record mc on mc.id = m.check_record_id
                         LEFT JOIN isc_materials_check_record mc on mc.id = m.check_record_id
                     <where>
                     <where>
-                        mc.reason = '1'
+                        m.deleted = 0 and mc.reason = '1'
                         <if test="startTime != null and startTime.trim != ''">
                         <if test="startTime != null and startTime.trim != ''">
                             and m.create_time &gt;= #{startTime}
                             and m.create_time &gt;= #{startTime}
                         </if>
                         </if>
@@ -185,6 +190,7 @@
                         </if>
                         </if>
                     </where>
                     </where>
                     GROUP BY ma.materials_type_id ) c ON c.materials_type_id = t.id
                     GROUP BY ma.materials_type_id ) c ON c.materials_type_id = t.id
+        where t.deleted = 0
         order by t.id asc
         order by t.id asc
     </select>
     </select>
     <select id="getUserLoanStatistics" resultType="cn.iocoder.yudao.module.iscs.controller.admin.statistics.vo.UserLoanStatisticsVO">
     <select id="getUserLoanStatistics" resultType="cn.iocoder.yudao.module.iscs.controller.admin.statistics.vo.UserLoanStatisticsVO">
@@ -197,9 +203,10 @@
         u.id as user_id,
         u.id as user_id,
         u.username as user_name,
         u.username as user_name,
         u.nickname as nick_name
         u.nickname as nick_name
-        FROM isc_materials_loan l LEFT JOIN system_users u ON u.id = l.loan_user_id  GROUP BY u.id) a
+        FROM isc_materials_loan l LEFT JOIN system_users u ON u.id = l.loan_user_id where l.deleted = 0 GROUP BY u.id) a
         LEFT JOIN (SELECT l.loan_user_id, count(l.id) as all_count from isc_materials_loan l
         LEFT JOIN (SELECT l.loan_user_id, count(l.id) as all_count from isc_materials_loan l
         <where>
         <where>
+            l.deleted = 0
             <if test="startTime != null and startTime.trim != ''">
             <if test="startTime != null and startTime.trim != ''">
                 and l.create_time &gt;= #{startTime}
                 and l.create_time &gt;= #{startTime}
             </if>
             </if>
@@ -210,7 +217,7 @@
         GROUP BY l.loan_user_id) b on b.loan_user_id = a.user_id
         GROUP BY l.loan_user_id) b on b.loan_user_id = a.user_id
         LEFT JOIN (SELECT l.loan_user_id, count(l.id) as normal_count from isc_materials_loan l
         LEFT JOIN (SELECT l.loan_user_id, count(l.id) as normal_count from isc_materials_loan l
         <where>
         <where>
-            l.actual_restitution_time &lt;= l.reminder_time
+            l.deleted = 0 and l.actual_restitution_time &lt;= l.reminder_time
             <if test="startTime != null and startTime.trim != ''">
             <if test="startTime != null and startTime.trim != ''">
                 and l.create_time &gt;= #{startTime}
                 and l.create_time &gt;= #{startTime}
             </if>
             </if>
@@ -221,7 +228,7 @@
         GROUP BY l.loan_user_id) c on b.loan_user_id = a.user_id
         GROUP BY l.loan_user_id) c on b.loan_user_id = a.user_id
         LEFT JOIN (SELECT l.loan_user_id, count(l.id) as timeout_count from isc_materials_loan l
         LEFT JOIN (SELECT l.loan_user_id, count(l.id) as timeout_count from isc_materials_loan l
         <where>
         <where>
-            l.actual_restitution_time &gt; l.reminder_time
+            l.deleted = 0 and l.actual_restitution_time &gt; l.reminder_time
             <if test="startTime != null and startTime.trim != ''">
             <if test="startTime != null and startTime.trim != ''">
                 and l.create_time &gt;= #{startTime}
                 and l.create_time &gt;= #{startTime}
             </if>
             </if>
@@ -244,9 +251,9 @@
         cross join (select 0 as a union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) as c
         cross join (select 0 as a union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) as c
         cross join (select 0 as a union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) as d
         cross join (select 0 as a union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) as d
         ) a where a.Date between #{startTime} and #{endTime}) a
         ) a where a.Date between #{startTime} and #{endTime}) a
-        left join (select count(l.id) as all_count, DATE_FORMAT(l.loan_time, '%Y-%m-%d') as date from isc_materials_loan l group by date) b on b.date = a.Date
-        left join (select count(l.id) as return_count, DATE_FORMAT(l.loan_time, '%Y-%m-%d') as date from isc_materials_loan l where DATE_FORMAT(l.loan_time, '%Y-%m-%d') between #{startTime} and #{endTime} and l.actual_restitution_time &lt;= l.reminder_time group by date) c on c.date = a.Date
-        left join (select count(l.id) as timeout_count, DATE_FORMAT(l.loan_time, '%Y-%m-%d') as date from isc_materials_loan l where DATE_FORMAT(l.loan_time, '%Y-%m-%d') between #{startTime} and #{endTime} and l.actual_restitution_time &gt; l.reminder_time group by date) d on d.date = a.Date
+        left join (select count(l.id) as all_count, DATE_FORMAT(l.loan_time, '%Y-%m-%d') as date from isc_materials_loan l where l.deleted = 0 group by date) b on b.date = a.Date
+        left join (select count(l.id) as return_count, DATE_FORMAT(l.loan_time, '%Y-%m-%d') as date from isc_materials_loan l where l.deleted = 0 and DATE_FORMAT(l.loan_time, '%Y-%m-%d') between #{startTime} and #{endTime} and l.actual_restitution_time &lt;= l.reminder_time group by date) c on c.date = a.Date
+        left join (select count(l.id) as timeout_count, DATE_FORMAT(l.loan_time, '%Y-%m-%d') as date from isc_materials_loan l where l.deleted = 0 and DATE_FORMAT(l.loan_time, '%Y-%m-%d') between #{startTime} and #{endTime} and l.actual_restitution_time &gt; l.reminder_time group by date) d on d.date = a.Date
         ORDER BY a.date DESC
         ORDER BY a.date DESC
     </select>
     </select>
     <select id="getOngoingJobList" resultType="cn.iocoder.yudao.module.iscs.controller.admin.statistics.vo.OngoingJobVO">
     <select id="getOngoingJobList" resultType="cn.iocoder.yudao.module.iscs.controller.admin.statistics.vo.OngoingJobVO">
@@ -263,6 +270,7 @@
             isc_job_ticket j
             isc_job_ticket j
                 LEFT JOIN isc_workstation w ON w.id = j.workstation_id
                 LEFT JOIN isc_workstation w ON w.id = j.workstation_id
                 LEFT JOIN isc_machinery ma ON ma.id = j.machinery_id
                 LEFT JOIN isc_machinery ma ON ma.id = j.machinery_id
+        where j.deleted = 0
         ORDER BY j.id DESC
         ORDER BY j.id DESC
     </select>
     </select>
     <select id="getLoanList" resultType="cn.iocoder.yudao.module.iscs.controller.admin.statistics.vo.HomePageLoanVO">
     <select id="getLoanList" resultType="cn.iocoder.yudao.module.iscs.controller.admin.statistics.vo.HomePageLoanVO">
@@ -277,8 +285,8 @@
             cross join (select 0 as a union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) as c
             cross join (select 0 as a union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) as c
             cross join (select 0 as a union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) as d
             cross join (select 0 as a union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) as d
             ) a where a.Date between #{startTime} and #{endTime}) a
             ) a where a.Date between #{startTime} and #{endTime}) a
-            left join (select count(l.id) as loan_count, DATE_FORMAT(l.loan_time, '%Y-%m-%d') as date from isc_materials_loan l where DATE_FORMAT(l.loan_time, '%Y-%m-%d') between #{startTime} and #{endTime} group by date) b on b.date = a.Date
-            left join (select count(l.id) as return_count, DATE_FORMAT(l.loan_time, '%Y-%m-%d') as date from isc_materials_loan l where DATE_FORMAT(l.loan_time, '%Y-%m-%d') between #{startTime} and #{endTime} and l.status = "1" group by date) c on c.date = a.Date
+            left join (select count(l.id) as loan_count, DATE_FORMAT(l.loan_time, '%Y-%m-%d') as date from isc_materials_loan l where l.deleted = 0 and DATE_FORMAT(l.loan_time, '%Y-%m-%d') between #{startTime} and #{endTime} group by date) b on b.date = a.Date
+            left join (select count(l.id) as return_count, DATE_FORMAT(l.loan_time, '%Y-%m-%d') as date from isc_materials_loan l where l.deleted = 0 and DATE_FORMAT(l.loan_time, '%Y-%m-%d') between #{startTime} and #{endTime} and l.status = "1" group by date) c on c.date = a.Date
         ORDER BY a.date DESC
         ORDER BY a.date DESC
     </select>
     </select>