diff --git a/jero-boot-incoming-payment/src/main/java/com/jero/drafting/controller/PayDraftingGroupSubItemController.java b/jero-boot-incoming-payment/src/main/java/com/jero/drafting/controller/PayDraftingGroupSubItemController.java index cd5af935..b482463e 100644 --- a/jero-boot-incoming-payment/src/main/java/com/jero/drafting/controller/PayDraftingGroupSubItemController.java +++ b/jero-boot-incoming-payment/src/main/java/com/jero/drafting/controller/PayDraftingGroupSubItemController.java @@ -12,10 +12,6 @@ import com.jero.common.system.vo.LoginUser; import com.jero.common.util.PasswordUtil; import com.jero.common.util.ValidUtil; import com.jero.common.util.oConvertUtils; -import com.jero.contract.entity.PayIncomeContract; -import com.jero.contract.entity.PayIncomeContractAssociated; -import com.jero.contract.service.IPayIncomeContractAssociatedService; -import com.jero.contract.service.IPayIncomeContractService; import com.jero.drafting.common.DraftingConstant; import com.jero.drafting.entity.PayDraftingGroup; import com.jero.drafting.entity.PayDraftingGroupSubItem; @@ -25,17 +21,8 @@ import com.jero.drafting.service.IPayDraftingGroupSubItemContactsService; import com.jero.drafting.service.IPayDraftingGroupSubItemService; import com.jero.drafting.vo.CheckVo; import com.jero.drafting.vo.PayDraftingGroupSubItemExcel; -import com.jero.mail.entity.PayMailBill; -import com.jero.mail.entity.PayMailBillProject; -import com.jero.mail.service.IPayMailBillProjectService; -import com.jero.mail.service.IPayMailBillService; import com.jero.modules.system.entity.SysUser; import com.jero.modules.system.service.ISysUserService; -import com.jero.pack.entity.PayPackCompany; -import com.jero.pack.entity.PayPackCompanyProject; -import com.jero.pack.service.IPayPackCompanyProjectService; -import com.jero.pack.service.IPayPackCompanyService; -import com.jero.project.common.PayProjectCommon; import com.jero.temporary.entity.PayContactsManagementTemporary; import com.jero.temporary.service.IPayContactsManagementTemporaryService; import io.swagger.annotations.Api; @@ -305,7 +292,7 @@ public class PayDraftingGroupSubItemController extends JeroController queryDraftingGroupSubItemContacts = new LambdaQueryWrapper<>(); + queryDraftingGroupSubItemContacts.eq(PayDraftingGroupSubItemContacts::getDraftingGroupSubId, draftingGroupSubItemId); + queryDraftingGroupSubItemContacts.eq(PayDraftingGroupSubItemContacts::getContactsId,sysUser.getId()); + long l = payDraftingGroupSubItemContactsService.count(queryDraftingGroupSubItemContacts); + if(l == 0){ + throw new JeroBootException("非起草组成员不可操作!"); + } + + try { + // 编辑保存前再次校验来款项目是否存在 + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(PayDraftingGroupSubItem::getDraftingGroupId, payDraftingGroupSubItem.getDraftingGroupId()); + queryWrapper.eq(PayDraftingGroupSubItem::getChargeCompanyId, payDraftingGroupSubItem.getChargeCompanyId()); + PayDraftingGroupSubItem payDraftingGroupSubItemNew = payDraftingGroupSubItemService.getOne(queryWrapper); + // 企业和联系人同时存在,则校验不通过 + if (!Objects.isNull(payDraftingGroupSubItemNew) && !Objects.equals(payDraftingGroupSubItemNew.getId(), draftingGroupSubItemId)) { + throw new JeroBootException("起草组成员单位已存在!"); + } + } catch (Exception e) { + throw new JeroBootException("起草组成员单位已存在!"); + } + LambdaQueryWrapper queryPayDraftingGroupSubItemContacts = new LambdaQueryWrapper<>(); + queryPayDraftingGroupSubItemContacts.eq(PayDraftingGroupSubItemContacts::getDraftingGroupSubId, payDraftingGroupSubItemOld.getId()); + List listPayDraftingGroupSubItemContacts = payDraftingGroupSubItemContactsService.list(queryPayDraftingGroupSubItemContacts); + if (!CollectionUtils.isEmpty(listPayDraftingGroupSubItemContacts)) { + payDraftingGroupSubItemOld.setPayDraftingGroupSubItemContactsList(listPayDraftingGroupSubItemContacts); + } + setPayDraftingGroupSubItemEdit(payDraftingGroupSubItem, payDraftingGroupSubItemOld); + List listPayDraftingGroupSubItemContactsNew = payDraftingGroupSubItem.getPayDraftingGroupSubItemContactsList(); + // 添加联系人表 + if (!CollectionUtils.isEmpty(listPayDraftingGroupSubItemContactsNew)) { + // 先删除之前的企业联系人 + LambdaUpdateWrapper updatePayWorkingGroupSubItemContacts = new LambdaUpdateWrapper<>(); + updatePayWorkingGroupSubItemContacts.eq(PayDraftingGroupSubItemContacts::getDraftingGroupSubId, draftingGroupSubItemId); + payDraftingGroupSubItemContactsService.remove(updatePayWorkingGroupSubItemContacts); + // 添加新的企业联系人 + for (int i = 0; i < listPayDraftingGroupSubItemContactsNew.size(); i++) { + listPayDraftingGroupSubItemContactsNew.get(i).setOrderNum(i + 1); + listPayDraftingGroupSubItemContactsNew.get(i).setDraftingGroupSubId(draftingGroupSubItemId); + listPayDraftingGroupSubItemContactsNew.get(i).setDraftingGroupId(payDraftingGroupSubItem.getDraftingGroupId()); + } + payDraftingGroupSubItemContactsService.saveBatch(listPayDraftingGroupSubItemContactsNew); + } + payDraftingGroupSubItemService.updateById(payDraftingGroupSubItem); + } + /** * 插入企业信息,联系人信息到临时表,更新项目记录 *