|
@@ -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));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|