ezhizao_zx há 1 ano atrás
pai
commit
c6c443f1a6

+ 2 - 0
src/main/java/cn/ezhizao/project/business/order/mapper/BizArchiveInputMapper.java

@@ -27,4 +27,6 @@ public interface BizArchiveInputMapper extends BaseMapper<BizArchiveInput>
      * @return 删除结果
     */
     public int physicalDelete(BizArchiveInput bizArchiveInput);
+
+    int removeByIds(List<Long> ids);
 }

+ 2 - 0
src/main/java/cn/ezhizao/project/business/order/service/IBizArchiveInputService.java

@@ -43,4 +43,6 @@ public interface IBizArchiveInputService extends IService<BizArchiveInput>
     String importLoop(List<OrderExcelImportLoopModel> orderList, Long userId, long l);
 
     String importOnce(List<OrderExcelImportOnceModel> orderList, Long userId, long l);
+
+    int removeBinByIds(List<Long> ids);
 }

+ 5 - 0
src/main/java/cn/ezhizao/project/business/order/service/impl/BizArchiveInputServiceImpl.java

@@ -1710,4 +1710,9 @@ public class BizArchiveInputServiceImpl extends ServiceImpl<BizArchiveInputMappe
         }
         return successMsg.toString();
     }
+
+    @Override
+    public int removeBinByIds(List<Long> ids) {
+        return bizArchiveInputMapper.removeByIds(ids);
+    }
 }

+ 135 - 12
src/main/java/cn/ezhizao/project/business/recycleBin/controller/BizRecycleBinController.java

@@ -5,13 +5,27 @@ import java.util.stream.Collectors;
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletResponse;
 
+import cn.ezhizao.common.exception.ServiceException;
 import cn.ezhizao.project.business.company.domain.BizCompany;
 import cn.ezhizao.project.business.company.mapper.BizCompanyMapper;
 import cn.ezhizao.project.business.company.service.IBizCompanyService;
+import cn.ezhizao.project.business.order.domain.BizArchiveInput;
+import cn.ezhizao.project.business.order.domain.BizArchiveInputDetail;
+import cn.ezhizao.project.business.order.domain.BizArchiveInputDetailProcess;
+import cn.ezhizao.project.business.order.service.IBizArchiveInputDetailService;
+import cn.ezhizao.project.business.order.service.IBizArchiveInputService;
 import cn.ezhizao.project.business.recycleBin.domain.BizRecycleBin;
 import cn.ezhizao.project.business.recycleBin.service.IBizRecycleBinService;
+import cn.ezhizao.project.business.workOrder.domain.BizWorkOrder;
+import cn.ezhizao.project.business.workOrder.domain.BizWorkOrderDetail;
+import cn.ezhizao.project.business.workOrder.domain.BizWorkOrderRecord;
+import cn.ezhizao.project.business.workOrder.service.IBizWorkOrderDetailService;
+import cn.ezhizao.project.business.workOrder.service.IBizWorkOrderRecordService;
+import cn.ezhizao.project.business.workOrder.service.IBizWorkOrderService;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import lombok.Getter;
 import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.PutMapping;
@@ -42,6 +56,21 @@ public class BizRecycleBinController extends BaseController {
     @Resource
     private IBizCompanyService bizCompanyService;
 
+    @Resource
+    private IBizArchiveInputDetailService bizArchiveInputDetailService;
+
+    @Resource
+    private IBizWorkOrderDetailService bizWorkOrderDetailService;
+
+    @Resource
+    private IBizWorkOrderRecordService bizWorkOrderRecordService;
+
+    @Resource
+    private IBizArchiveInputService bizArchiveInputService;
+
+    @Resource
+    private IBizWorkOrderService bizWorkOrderService;
+
     @Resource
     private BizCompanyMapper bizCompanyMapper;
 
@@ -57,7 +86,11 @@ public class BizRecycleBinController extends BaseController {
             "biz_housing_fund_confirm_detail", "biz_housing_fund_confirm_detail_employee", "biz_housing_fund_declare", "biz_housing_fund_declare_detail",
             "biz_social_security_confirm", "biz_social_security_confirm_detail", "biz_social_security_confirm_detail_employee",
             "biz_social_security_declare", "biz_social_security_declare_detail"};
+    //订单关联的数据表
+    @Getter
+    private String[] ordertabs = {"biz_archive_input_detail", "biz_archive_input_detail_process", "biz_work_order", "biz_work_order_detail"
 
+    };
 
     /**
      * 查询回收站列表
@@ -140,13 +173,12 @@ public class BizRecycleBinController extends BaseController {
     @PreAuthorize("@ss.hasPermi('business:bin:add')")
     @Log(title = "回收站", businessType = BusinessType.INSERT)
     @PostMapping("/old/{ids}")
-    public void addOld(@PathVariable List<Long> ids) throws NoSuchFieldException, IllegalAccessException
-    {
-        BizCompany com=new BizCompany();
+    public void addOld(@PathVariable List<Long> ids) throws NoSuchFieldException, IllegalAccessException {
+        BizCompany com = new BizCompany();
         //遍历id查询客户数据并在回收站中插入
-        for (Long id:ids) {
-            BizRecycleBin bin =new BizRecycleBin();
-            com=bizCompanyMapper.getById(id);
+        for (Long id : ids) {
+            BizRecycleBin bin = new BizRecycleBin();
+            com = bizCompanyMapper.getById(id);
             bin.setFromId(0L);
             bin.setSourceValue(com.getName());
             bin.setSourceTableName("biz_company");
@@ -154,15 +186,94 @@ public class BizRecycleBinController extends BaseController {
             setTenantId(bin);
             bizRecycleBinService.save(bin);
             //软删除客户关联子表数据
-            bizRecycleBinService.deleteData(id,tabs);
+            bizRecycleBinService.deleteData(id, tabs);
 
             //查询客户关联子表数据在回收站中插入
-            for (String tab:tabs) {
+            for (String tab : tabs) {
+                //查询客户关联子表id
+                Long childId = bizRecycleBinService.getChildById(id, tab);
+                //如果返回id不为空则将数据插入回收站
+                if (childId != null && !childId.equals("")) {
+                    BizRecycleBin rbiz = new BizRecycleBin();
+                    rbiz.setFromId(bin.getId());
+                    rbiz.setSourceValue(com.getName());
+                    rbiz.setSourceTableName(tab);
+                    rbiz.setSourceId(childId);
+                    setTenantId(rbiz);
+                    bizRecycleBinService.save(rbiz);
+                }
+            }
+        }
+    }
+
+    @PreAuthorize("@ss.hasPermi('business:archive:order:bin')")
+    @Log(title = "订单回收站", businessType = BusinessType.INSERT)
+    @PostMapping("/order/{ids}")
+    @Transactional(rollbackFor = Exception.class)
+    public AjaxResult addOrder(@PathVariable List<Long> ids) throws NoSuchFieldException, IllegalAccessException {
+
+        // 判断是否可以删除
+        if (bizArchiveInputService.query().in("id", ids).eq("contract_type", 1).count() > 0) {
+            throw new ServiceException("续签合同无法放入回收站");
+        } else if (bizArchiveInputService.query().in("id", ids).eq("status", 8).count() > 0) {
+            throw new ServiceException("合同变更不能放入回收站");
+        } else if (bizArchiveInputService.query().in("id", ids).eq("status", 9).count() > 0) {
+            throw new ServiceException("合同已解除不能放入回收站");
+        } else if (bizArchiveInputService.query().in("id", ids).eq("verify_status", 0).count() > 0) {
+            throw new ServiceException("未审核合同无法放入回收站。");
+        }
+
+        //循环判断订单是否已经开始,是否有续签订单
+        for (Long id : ids) {
+            //订单明细
+            BizArchiveInputDetail bizArchiveInputDetail = new BizArchiveInputDetail();
+            bizArchiveInputDetail.setContractId(id);
+            BizArchiveInputDetail detail = bizArchiveInputDetailService.getDetail(bizArchiveInputDetail);
+
+            //合同工单
+            BizWorkOrder bizWorkOrder = new BizWorkOrder();
+            bizWorkOrder.setContractDetailId(detail.getId());
+            List<BizWorkOrder> workOrders = bizWorkOrderService.getList(bizWorkOrder);
+            for (BizWorkOrder workOrder : workOrders) {
+                //查询工单明细
+                BizWorkOrderDetail workOrderDetail = new BizWorkOrderDetail();
+                workOrderDetail.setWorkOrderId(workOrder.getId());
+                List<BizWorkOrderDetail> detailList = bizWorkOrderDetailService.getList(workOrderDetail);
+                if (detailList.size() > 1) {
+                    throw new ServiceException("有续签订单无法删除");
+                }
+                //判断工单是否已经开始
+                BizWorkOrderRecord bizWorkOrderRecord = new BizWorkOrderRecord();
+                bizWorkOrderRecord.setWorkOrderId(workOrder.getId());
+                List<BizWorkOrderRecord> bizWorkOrderRecords = bizWorkOrderRecordService.getList(bizWorkOrderRecord);
+                if (bizWorkOrderRecords.size() > 0) {
+                    throw new ServiceException("合同已经开始无法删除");
+                }
+            }
+        }
+
+        //遍历id查询订单数据数据并在回收站中插入
+        for (Long id : ids) {
+            BizArchiveInput archiveInput = new BizArchiveInput();
+            BizRecycleBin bin = new BizRecycleBin();
+            archiveInput = bizArchiveInputService.getById(id);
+            BizCompany com = bizCompanyService.getById(archiveInput.getCompanyId());
+            bin.setFromId(0L);
+            bin.setSourceValue(com.getName());
+            bin.setSourceTableName("biz_archive_input");
+            bin.setSourceId(archiveInput.getId());
+            setTenantId(bin);
+            bizRecycleBinService.save(bin);
+            //软删除订单关联子表数据
+            bizRecycleBinService.deleteArchiveData(id, ordertabs);
+
+            //查询订单关联子表数据在回收站中插入
+            for (String tab : ordertabs) {
                 //查询客户关联子表id
-                Long childId=bizRecycleBinService.getChildById(id,tab);
+                Long childId = bizRecycleBinService.getArchiveById(id, tab);
                 //如果返回id不为空则将数据插入回收站
-                if (childId!=null&& !childId.equals("")){
-                    BizRecycleBin rbiz =new BizRecycleBin();
+                if (childId != null && !childId.equals("")) {
+                    BizRecycleBin rbiz = new BizRecycleBin();
                     rbiz.setFromId(bin.getId());
                     rbiz.setSourceValue(com.getName());
                     rbiz.setSourceTableName(tab);
@@ -172,6 +283,7 @@ public class BizRecycleBinController extends BaseController {
                 }
             }
         }
+        return toAjax(bizArchiveInputService.removeBinByIds(ids));
     }
 
 
@@ -203,6 +315,17 @@ public class BizRecycleBinController extends BaseController {
     @PreAuthorize("@ss.hasPermi('business:bin:restore')")
     @PostMapping("/restore/{ids}")
     public AjaxResult restore(@PathVariable List<Long> ids) {
-        return toAjax(bizRecycleBinService.restore(ids));
+        return toAjax(bizRecycleBinService.restore(ids, tabs, true));
     }
+
+    /**
+     * 还原回收站
+     */
+    @PreAuthorize("@ss.hasPermi('business:bin:restore')")
+    @PostMapping("/restoreArchive/{ids}")
+    public AjaxResult restoreArchive(@PathVariable List<Long> ids) {
+        return toAjax(bizRecycleBinService.restore(ids, ordertabs, false));
+    }
+
+
 }

+ 7 - 0
src/main/java/cn/ezhizao/project/business/recycleBin/mapper/BizRecycleBinMapper.java

@@ -72,4 +72,11 @@ public interface BizRecycleBinMapper extends BaseMapper<BizRecycleBin>
 
     List<BizRecycleBin> getChildIdsByParentId(List<Map<String, Object>> tabs);
 
+    void deleteArchiveData(Long id, String[] tabs);
+
+    Long getArchiveById(Long id, String tab);
+
+    int restoreArchive(Long sourceId);
+
+    void restoreArchiveData(Long id, String[] tabs);
 }

+ 4 - 1
src/main/java/cn/ezhizao/project/business/recycleBin/service/IBizRecycleBinService.java

@@ -45,9 +45,12 @@ public interface IBizRecycleBinService extends IService<BizRecycleBin>
 
     /** 还原回收站
      * @return*/
-    int restore(List<Long> ids);
+    int restore(List<Long> ids,String [] tabs,boolean isCompany);
 
     /** 清除回收站 */
     int remove(List<Long> ids);
 
+    void deleteArchiveData(Long id, String[] tabs);
+
+    Long getArchiveById(Long id, String tab);
 }

+ 44 - 23
src/main/java/cn/ezhizao/project/business/recycleBin/service/impl/BizRecycleBinServiceImpl.java

@@ -23,19 +23,18 @@ import org.springframework.stereotype.Service;
  * @date 2023-11-02
  */
 @Service
-public class BizRecycleBinServiceImpl  extends ServiceImpl<BizRecycleBinMapper, BizRecycleBin> implements IBizRecycleBinService
-{
+public class BizRecycleBinServiceImpl extends ServiceImpl<BizRecycleBinMapper, BizRecycleBin> implements IBizRecycleBinService {
     @Resource
     private BizRecycleBinMapper bizRecycleBinMapper;
 
     @Resource
     private BizCompanyMapper bizCompanyMapper;
 
-    private BizRecycleBinController bizController=new BizRecycleBinController();
+    private BizRecycleBinController bizController = new BizRecycleBinController();
 
 
+    BaseController bcl = new BaseController();
 
-    BaseController bcl=new BaseController();
     /**
      * 查询回收站列表
      *
@@ -43,38 +42,48 @@ public class BizRecycleBinServiceImpl  extends ServiceImpl<BizRecycleBinMapper,
      * @return 回收站
      */
     @Override
-    public List<BizRecycleBin> getList(BizRecycleBin bizRecycleBin)
-    {
+    public List<BizRecycleBin> getList(BizRecycleBin bizRecycleBin) {
         return bizRecycleBinMapper.getList(bizRecycleBin);
     }
 
     /**
      * 物理删除
+     *
      * @param bizRecycleBin
      * @return 删除结果
      */
     @Override
-    public int physicalDelete(BizRecycleBin bizRecycleBin){ return bizRecycleBinMapper.physicalDelete(bizRecycleBin); };
+    public int physicalDelete(BizRecycleBin bizRecycleBin) {
+        return bizRecycleBinMapper.physicalDelete(bizRecycleBin);
+    }
+
+    ;
 
     /**
      * 还原
+     *
      * @return
      */
     @Override
-    public int restore(List<Long> ids){
-        String [] tabs= bizController.getTabs();
-        for (Long id:ids) {
+    public int restore(List<Long> ids, String[] tabs, boolean isCompany) {
+        for (Long id : ids) {
             //回收站数据还原
             bizRecycleBinMapper.restore(id);
             //获取要还原的数据
-            BizRecycleBin bin=bizRecycleBinMapper.getById(id);
-            //还原用户表数据
-            bizRecycleBinMapper.restoreCompany(bin.getSourceId());
-            //还原子表数据
-            bizRecycleBinMapper.restoreData(bin.getSourceId(),tabs);
+            BizRecycleBin bin = bizRecycleBinMapper.getById(id);
+
+            if (isCompany) {
+                //还原用户表数据
+                bizRecycleBinMapper.restoreCompany(bin.getSourceId());
+                //还原子表数据
+                bizRecycleBinMapper.restoreData(bin.getSourceId(), tabs);
+            }else {
+                //还原订单表数据
+                bizRecycleBinMapper.restoreArchive(bin.getSourceId());
+                //还原子表数据
+                bizRecycleBinMapper.restoreArchiveData(bin.getSourceId(), tabs);
+            }
 
-//            for (String tab:tabs) {
-//            }
 
         }
         return 1;
@@ -82,28 +91,40 @@ public class BizRecycleBinServiceImpl  extends ServiceImpl<BizRecycleBinMapper,
 
     /**
      * 删除
+     *
      * @return
      */
     @Override
-    public int remove(List<Long> ids){
-        for (Long id: ids) {
+    public int remove(List<Long> ids) {
+        for (Long id : ids) {
             bizRecycleBinMapper.remove(id);
         }
         return 1;
     }
 
+    @Override
+    public void deleteArchiveData(Long id, String[] tabs) {
+        bizRecycleBinMapper.deleteArchiveData(id, tabs);
+    }
+
+    @Override
+    public Long getArchiveById(Long id, String tab) {
+        return bizRecycleBinMapper.getArchiveById(id, tab);
+    }
+
     /**
      * 删除客户关联的子表数据
+     *
      * @return
      */
     @Override
-    public void deleteData(Long id, String[] tabs){
-        bizRecycleBinMapper.deleteData(id,tabs);
+    public void deleteData(Long id, String[] tabs) {
+        bizRecycleBinMapper.deleteData(id, tabs);
     }
 
     @Override
-    public Long getChildById (Long id, String tab){
-        return bizRecycleBinMapper.getChildById(id,tab);
+    public Long getChildById(Long id, String tab) {
+        return bizRecycleBinMapper.getChildById(id, tab);
     }
 
     @Override

+ 1 - 1
src/main/java/cn/ezhizao/project/business/settings/controller/BizSourceController.java

@@ -37,7 +37,7 @@ public class BizSourceController extends BaseController
     /**
      * 查询来源列表
      */
-    @PreAuthorize("@ss.hasPermi('settings:source:list')")
+//    @PreAuthorize("@ss.hasPermi('settings:source:list')")
     @GetMapping("/list")
     public TableDataInfo list(BizSource bizSource) throws NoSuchFieldException, IllegalAccessException
     {

+ 2 - 1
src/main/java/cn/ezhizao/project/business/workOrder/controller/WorkOrderServiceController.java

@@ -104,11 +104,11 @@ public class WorkOrderServiceController extends BaseController {
 
     @PreAuthorize("@ss.hasPermi('business:customer:service:loop:list')")
     @GetMapping("/list")
+
     public TableDataInfo list(BizWorkOrder bizWorkOrder) throws NoSuchFieldException, IllegalAccessException
     {
         setTenantId(bizWorkOrder);
         bizWorkOrder.setType(1);
-        bizWorkOrder.setIsStop(0);
         startPage();
         startOrderBy();
         List<BizWorkOrder> list = bizWorkOrderService.getList(bizWorkOrder);
@@ -359,6 +359,7 @@ public class WorkOrderServiceController extends BaseController {
         BizWorkOrder workOrder = bizWorkOrderService.getById(bizWorkOrderRecord.getWorkOrderId());
         setTenantId(bizWorkOrderRecord);
         boolean status = bizWorkOrderRecordService.saveOrUpdate(bizWorkOrderRecord);
+        bizWorkOrderRecord.setStatus(bizWorkOrderRecord.getStatus() == null ? 0 : bizWorkOrderRecord.getStatus());
         if (workOrder.getTaskTypeId().equals(1L)) {
             // 保存所有记账项
             BizFinancialSalaryDetail salaryDetail = bizWorkOrderRecord.getSalary();

+ 9 - 0
src/main/resources/mybatis/business/BizArchiveInputMapper.xml

@@ -106,6 +106,15 @@
         </trim>
     </select>
 
+    <update id="removeByIds">
+        UPDATE biz_archive_input
+        SET deleted=1
+        WHERE id in
+        <foreach collection="ids" item="id" index="index" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </update>
+
     <delete id="physicalDelete">
         DELETE FROM biz_archive_input
         <trim prefix=" WHERE" suffix="" suffixOverrides="AND">

+ 42 - 9
src/main/resources/mybatis/business/BizRecycleBinMapper.xml

@@ -16,8 +16,8 @@
             AND from_id = 0
             AND is_return = 0
             AND is_clean=0
-            <if test="sourceTableName != null  and sourceTableName != ''">AND source_table_name like concat('%',
-                #{sourceTableName}, '%')
+            <if test="sourceTableName != null  and sourceTableName != ''">AND source_table_name=#{sourceTableName}
+
             </if>
             <if test="sourceValue != null  and sourceValue != ''">AND source_value like concat('%', #{sourceValue},
                 '%')
@@ -42,33 +42,51 @@
         FROM biz_recycle_bin
         WHERE id = #{id}
     </select>
-<!--    &#45;&#45;         UPDATE ${table} t-->
-<!--    &#45;&#45;         SET t.deleted=1-->
-<!--    &#45;&#45;         WHERE t.company_id = ${id}-->
+    <!--    &#45;&#45;         UPDATE ${table} t-->
+    <!--    &#45;&#45;         SET t.deleted=1-->
+    <!--    &#45;&#45;         WHERE t.company_id = ${id}-->
     <!--  软删除客户关联子表数据  -->
     <update id="deleteData">
-        <foreach collection="tabs" item="item" index="index"  separator=";">
+        <foreach collection="tabs" item="item" index="index" separator=";">
             UPDATE ${item}
             SET deleted=1
             WHERE company_id=#{id}
         </foreach>
+    </update>
 
+    <!--  软删除客户关联子表数据  -->
+    <update id="deleteArchiveData">
+        <foreach collection="tabs" item="item" index="index" separator=";">
+            UPDATE ${item}
+            SET deleted=1
+            WHERE contract_id=#{id}
+        </foreach>
     </update>
 
     <!--  还原客户关联子表数据  -->
     <update id="restoreData">
-        <foreach collection="tabs" item="item" index="index"  separator=";">
+        <foreach collection="tabs" item="item" index="index" separator=";">
             UPDATE ${item}
             SET deleted=0
             WHERE company_id=#{id}
         </foreach>
     </update>
 
+    <!--  还原订单关联子表数据  -->
+    <update id="restoreArchiveData">
+        <foreach collection="tabs" item="item" index="index" separator=";">
+            UPDATE ${item}
+            SET deleted=0
+            WHERE contract_id=#{id}
+        </foreach>
+    </update>
+
     <!--  回收站数据还原  -->
     <update id="restore">
         UPDATE biz_recycle_bin
         SET is_return=1
-        WHERE id = #{id} OR from_id=#{id}
+        WHERE id = #{id}
+           OR from_id = #{id}
     </update>
 
     <!--  回收站数据删除  -->
@@ -76,7 +94,8 @@
         UPDATE biz_recycle_bin
         SET is_clean=1,
             deleted=1
-        WHERE id = #{id} OR from_id=#{id}
+        WHERE id = #{id}
+           OR from_id = #{id}
     </update>
 
     <!--  还原用户表数据  -->
@@ -86,11 +105,25 @@
         WHERE id = #{id}
     </update>
 
+    <!--  还原订单表数据  -->
+    <update id="restoreArchive">
+        UPDATE biz_archive_input
+        SET deleted=0
+        WHERE id = #{id}
+    </update>
+
     <select id="getChildById" resultType="Long">
         SELECT t.id
         FROM ${table} t
         WHERE t.company_id = ${id}
     </select>
+
+    <select id="getArchiveById" resultType="Long">
+        SELECT t.id
+        FROM ${tab} t
+        WHERE t.contract_id = ${id}
+    </select>
+
     <select id="getChildIdsByParentId" resultMap="BizRecycleBinResult">
         <foreach collection="tabs" item="item" index="index" separator="union">
             SELECT t.id as source_id, #{item.tab} as source_table_name

+ 1 - 0
src/main/resources/mybatis/business/BizWorkOrderDetailMapper.xml

@@ -19,6 +19,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="id != null "> AND id = #{id}</if>
             <if test="workOrderId != null "> AND work_order_id = #{workOrderId}</if>
             <if test="companyId != null "> AND company_id = #{companyId}</if>
+            <if test="contractDetailId != null "> AND contract_detail_id = #{contractDetailId}</if>
             <if test="contractId != null "> AND contract_id = #{contractId}</if>
             <if test="serviceNum != null "> AND service_num = #{serviceNum}</if>
             <if test="freeNum != null "> AND free_num = #{freeNum}</if>

+ 1 - 0
src/main/resources/mybatis/business/BizWorkOrderMapper.xml

@@ -26,6 +26,7 @@
         <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
             t1.deleted = 0
             <if test="id != null "> AND t1.id = #{id}</if>
+            <if test="contractDetailId != null "> AND t1.contract_detail_id = #{contractDetailId}</if>
             <if test="tenantId != null "> AND t1.tenant_id = #{tenantId}</if>
             <if test="companyId != null "> AND t1.company_id = #{companyId}</if>
             <if test="type != null ">AND t1.type = #{type}</if>