Browse Source

fix:回收站删除和还原时逻辑判断修改sql增加

ly 9 tháng trước cách đây
mục cha
commit
694e19466f

+ 2 - 0
src/main/java/cn/ezhizao/project/business/company/mapper/BizCompanyMapper.java

@@ -28,4 +28,6 @@ public interface BizCompanyMapper extends BaseMapper<BizCompany>
      * @return 删除结果
      */
     public int physicalDelete(BizCompany bizCompany);
+
+    BizCompany getByComId(Long id);
 }

+ 1 - 0
src/main/java/cn/ezhizao/project/business/company/service/IBizCompanyService.java

@@ -20,6 +20,7 @@ public interface IBizCompanyService extends IService<BizCompany>
      * @return 客户信息
      */
     public BizCompany getById(Long id);
+    public BizCompany getByComId(Long id);
     /**
      * 查询company列表
      *

+ 5 - 0
src/main/java/cn/ezhizao/project/business/company/service/impl/BizCompanyServiceImpl.java

@@ -74,6 +74,11 @@ public class BizCompanyServiceImpl  extends ServiceImpl<BizCompanyMapper, BizCom
         return company;
     }
 
+    @Override
+    public BizCompany getByComId(Long id) {
+        return bizCompanyMapper.getByComId(id);
+    }
+
     /**
      * 查询company列表
      *

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

@@ -36,4 +36,6 @@ public interface BizArchiveInputMapper extends BaseMapper<BizArchiveInput>
     List<BizArchiveInput> getListByInput(InputVo bizArchiveInput);
 
     int deleteByDate(@Param("workOrderId")Long workOrderId, @Param("endDate")Date endDate, @Param("taskTypeId")Long taskTypeId,@Param("updaterId")Long updaterId);
+
+    BizArchiveInput getById(Long id);
 }

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

@@ -52,4 +52,5 @@ public interface IBizArchiveInputService extends IService<BizArchiveInput>
     boolean addLoopTasks(BizWorkOrder workOrder);
     boolean stopLoopTasks(BizWorkOrder workOrder);
     boolean saveDetailMonth(BizArchiveInput bizArchiveInput);
+    BizArchiveInput getById(Long id);
 }

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

@@ -452,6 +452,11 @@ public class BizArchiveInputServiceImpl extends ServiceImpl<BizArchiveInputMappe
         return true;
     }
 
+    @Override
+    public BizArchiveInput getById(Long id) {
+        return bizArchiveInputMapper.getById(id);
+    }
+
     private boolean stopHousingFund(BizWorkOrder workOrder) {
         List<Map<String, Object>> maps = Arrays.stream(housingFundTaskTableNames).map(v -> {
             Map<String, Object> map = new HashMap<>();

+ 15 - 28
src/main/java/cn/ezhizao/project/business/recycleBin/controller/BizRecycleBinController.java

@@ -142,38 +142,16 @@ public class BizRecycleBinController extends BaseController {
     @PostMapping("/{ids}")
     @Transactional(rollbackFor = Exception.class)
     public AjaxResult add(@PathVariable List<Long> ids) throws NoSuchFieldException, IllegalAccessException {
-        BizCompany com = new BizCompany();
-        List<BizRecycleBin> recycleBins = new ArrayList<>();
         //遍历id查询客户数据并在回收站中插入
+
         for (Long id : ids) {
-            BizRecycleBin bin = new BizRecycleBin();
-            com = bizCompanyMapper.getById(id);
-            bin.setFromId(0L);
-            bin.setSourceValue(com.getName());
-            bin.setSourceTableName("biz_company");
-            bin.setSourceId(com.getId());
-            setTenantId(bin);
-            bizRecycleBinService.save(bin);
-            //软删除客户关联子表数据
-            bizRecycleBinService.deleteData(id, tabs);
-            List<Map<String, Object>> tabList = Arrays.stream(tabs).map(v -> {
-                Map<String, Object> map = new HashMap<>();
-                map.put("tab", v);
-                map.put("id", id);
-                return map;
-            }).collect(Collectors.toList());
-            List<BizRecycleBin> children = bizRecycleBinService.getChildIdsByParentId(tabList);
-            Long tenantId = getTenantId();
-            BizCompany finalCom = com;
-            children.forEach(child -> {
-                child.setFromId(bin.getId());
-                child.setSourceValue(finalCom.getName());
-                child.setTenantId(tenantId);
-                recycleBins.add(child);
-            });
+            List<BizArchiveInput> bizArchiveInputList = bizArchiveInputService.query().eq("company_id",id).eq("verify_status",1).list();
+            if(!bizArchiveInputList.isEmpty()) {
+                return error("有合同正在进行,不可以删除客户");
+            }
         }
         //查询客户关联子表数据在回收站中插入
-        bizRecycleBinService.saveBatch(recycleBins);
+        //bizRecycleBinService.saveBatch(recycleBins);
         //删除客户表数据
         return toAjax(bizCompanyService.removeBatchByIds(ids));
     }
@@ -381,6 +359,15 @@ public class BizRecycleBinController extends BaseController {
     @PreAuthorize("@ss.hasPermi('business:bin:restore')")
     @PostMapping("/restoreArchive/{ids}")
     public AjaxResult restoreArchive(@PathVariable  List<Long> ids) {
+        BizArchiveInput bizArchiveInput;
+        BizCompany bizCompany;
+        for(Long id : ids){
+            bizArchiveInput = bizArchiveInputService.getById(id);
+            bizCompany = bizCompanyService.getByComId(bizArchiveInput.getCompanyId());
+            if(null != bizCompany && bizCompany.getDeleted() == 1L){
+                return error("此合同关联的用户,已被删除,只能进行删除操作");
+            }
+        }
         return toAjax(bizRecycleBinService.restore(ids, ordertabs, false));
     }
 

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

@@ -224,4 +224,8 @@
         </where>
 
     </delete>
+
+    <select id="getById" resultType="cn.ezhizao.project.business.order.domain.BizArchiveInput">
+        select * from biz_archive_input where id = #{id}
+    </select>
 </mapper>

+ 4 - 0
src/main/resources/mybatis/business/BizCompanyMapper.xml

@@ -156,4 +156,8 @@
             <!-- 删除条件为其他外键可以在这里加 -->
         </trim>
     </delete>
+
+    <select id="getByComId" resultType="cn.ezhizao.project.business.company.domain.BizCompany">
+        select * from biz_company where id = #{id}
+    </select>
 </mapper>