添加分包和供应商关联
This commit is contained in:
@ -6,8 +6,6 @@ import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
import org.dromara.common.core.validate.EditGroup;
|
||||
import org.dromara.common.excel.utils.ExcelUtil;
|
||||
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
||||
import org.dromara.common.log.annotation.Log;
|
||||
@ -99,7 +97,7 @@ public class SubContractorController extends BaseController {
|
||||
@Log(title = "分包单位", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Long> add(@Validated(AddGroup.class) @RequestBody SubContractorCreateReq req) {
|
||||
public R<Long> add(@Validated @RequestBody SubContractorCreateReq req) {
|
||||
return R.ok(contractorService.insertByBo(req));
|
||||
}
|
||||
|
||||
@ -110,7 +108,7 @@ public class SubContractorController extends BaseController {
|
||||
@Log(title = "分包单位", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody SubContractorUpdateReq req) {
|
||||
public R<Void> edit(@Validated @RequestBody SubContractorUpdateReq req) {
|
||||
return toAjax(contractorService.updateByBo(req));
|
||||
}
|
||||
|
||||
|
@ -40,6 +40,11 @@ public class SubContractor extends BaseEntity {
|
||||
*/
|
||||
private Long deptId;
|
||||
|
||||
/**
|
||||
* 供应商id
|
||||
*/
|
||||
private Long supplierId;
|
||||
|
||||
/**
|
||||
* 公司名称
|
||||
*/
|
||||
|
@ -1,5 +1,7 @@
|
||||
package org.dromara.contractor.domain.dto.contractor;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
@ -19,21 +21,31 @@ public class SubContractorCreateReq implements Serializable {
|
||||
/**
|
||||
* 项目id
|
||||
*/
|
||||
@NotNull(message = "项目不能为空")
|
||||
private Long projectId;
|
||||
|
||||
/**
|
||||
* 公司名称
|
||||
*/
|
||||
@NotBlank(message = "公司名称不能为空")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 供应商id
|
||||
*/
|
||||
@NotNull(message = "供应商不能为空")
|
||||
private Long supplierId;
|
||||
|
||||
/**
|
||||
* 负责人
|
||||
*/
|
||||
@NotBlank(message = "负责人不能为空")
|
||||
private String principal;
|
||||
|
||||
/**
|
||||
* 负责人联系电话
|
||||
*/
|
||||
@NotBlank(message = "负责人联系电话不能为空")
|
||||
private String principalPhone;
|
||||
|
||||
/**
|
||||
@ -54,6 +66,7 @@ public class SubContractorCreateReq implements Serializable {
|
||||
/**
|
||||
* 分包类型
|
||||
*/
|
||||
@NotBlank(message = "分包类型不能为空")
|
||||
private String contractorType;
|
||||
|
||||
/**
|
||||
|
@ -15,16 +15,16 @@ public class SubContractorQueryReq implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 3252651952758479341L;
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 项目id
|
||||
*/
|
||||
private Long projectId;
|
||||
|
||||
/**
|
||||
* 供应商id
|
||||
*/
|
||||
private Long supplierId;
|
||||
|
||||
/**
|
||||
* 公司名称
|
||||
*/
|
||||
|
@ -1,5 +1,6 @@
|
||||
package org.dromara.contractor.domain.dto.contractor;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
@ -19,6 +20,7 @@ public class SubContractorUpdateReq implements Serializable {
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@NotNull(message = "主键不能为空")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
@ -31,6 +33,11 @@ public class SubContractorUpdateReq implements Serializable {
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 供应商id
|
||||
*/
|
||||
private Long supplierId;
|
||||
|
||||
/**
|
||||
* 负责人
|
||||
*/
|
||||
|
@ -44,6 +44,16 @@ public class SubContractorVo implements Serializable {
|
||||
@ExcelProperty(value = "公司名称")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 供应商id
|
||||
*/
|
||||
private Long supplierId;
|
||||
|
||||
/**
|
||||
* 供应商名称
|
||||
*/
|
||||
private String supplierName;
|
||||
|
||||
/**
|
||||
* 负责人
|
||||
*/
|
||||
|
@ -32,6 +32,8 @@ import org.dromara.project.service.IBusProjectService;
|
||||
import org.dromara.system.domain.SysDept;
|
||||
import org.dromara.system.domain.enums.SysDeptTypeEnum;
|
||||
import org.dromara.system.mapper.SysDeptMapper;
|
||||
import org.dromara.tender.domain.TenderSupplierInput;
|
||||
import org.dromara.tender.service.ITenderSupplierInputService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -61,6 +63,9 @@ public class SubContractorServiceImpl extends ServiceImpl<SubContractorMapper, S
|
||||
@Resource
|
||||
private SysDeptMapper deptMapper;
|
||||
|
||||
@Resource
|
||||
private ITenderSupplierInputService supplierInputService;
|
||||
|
||||
/**
|
||||
* 查询分包单位
|
||||
*
|
||||
@ -153,7 +158,7 @@ public class SubContractorServiceImpl extends ServiceImpl<SubContractorMapper, S
|
||||
String fileMapStr = JSONUtil.toJsonStr(fileMap);
|
||||
contractor.setFiles(fileMapStr);
|
||||
// 数据校验
|
||||
validEntityBeforeSave(contractor, true);
|
||||
validEntityBeforeSave(contractor);
|
||||
String name = req.getName();
|
||||
Long count = this.lambdaQuery().eq(SubContractor::getName, name).count();
|
||||
if (count > 0) {
|
||||
@ -188,7 +193,7 @@ public class SubContractorServiceImpl extends ServiceImpl<SubContractorMapper, S
|
||||
String fileMapStr = JSONUtil.toJsonStr(fileMap);
|
||||
contractor.setFiles(fileMapStr);
|
||||
// 数据校验
|
||||
validEntityBeforeSave(contractor, false);
|
||||
validEntityBeforeSave(contractor);
|
||||
// 判断是否存在
|
||||
SubContractor oldContractor = this.getById(contractor.getId());
|
||||
if (oldContractor == null) {
|
||||
@ -208,29 +213,20 @@ public class SubContractorServiceImpl extends ServiceImpl<SubContractorMapper, S
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
private void validEntityBeforeSave(SubContractor entity, Boolean create) {
|
||||
private void validEntityBeforeSave(SubContractor entity) {
|
||||
// 做一些数据校验,如唯一约束
|
||||
String name = entity.getName();
|
||||
String principal = entity.getPrincipal();
|
||||
String principalPhone = entity.getPrincipalPhone();
|
||||
String custodianPhone = entity.getCustodianPhone();
|
||||
if (create) {
|
||||
if (StringUtils.isBlank(name)) {
|
||||
throw new ServiceException("分包单位名称不能为空", HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
if (StringUtils.isBlank(principal)) {
|
||||
throw new ServiceException("分包单位负责人不能为空", HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
if (StringUtils.isBlank(principalPhone)) {
|
||||
throw new ServiceException("分包单位负责人手机号不能为空", HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
Long supplierId = entity.getSupplierId();
|
||||
if (StringUtils.isNotBlank(principalPhone) && !PhoneUtil.isPhone(principalPhone)) {
|
||||
throw new ServiceException("负责人手机号格式不正确", HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
if (StringUtils.isNotBlank(custodianPhone) && !PhoneUtil.isPhone(custodianPhone)) {
|
||||
throw new ServiceException("管理人手机号格式不正确", HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
if (ObjectUtils.isNotEmpty(supplierId) && supplierInputService.getById(supplierId) == null) {
|
||||
throw new ServiceException("供应商不存在", HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -307,6 +303,14 @@ public class SubContractorServiceImpl extends ServiceImpl<SubContractorMapper, S
|
||||
JSONObject parseObj = JSONUtil.parseObj(files);
|
||||
parseObj.forEach((key, value) -> fileMap.put(key, (Long) value));
|
||||
contractorVo.setFileMap(fileMap);
|
||||
// 关联供应商名称
|
||||
Long supplierId = contractor.getSupplierId();
|
||||
if (supplierId != null) {
|
||||
TenderSupplierInput supplierInput = supplierInputService.getById(supplierId);
|
||||
if (supplierInput != null) {
|
||||
contractorVo.setSupplierName(supplierInput.getSupplierName());
|
||||
}
|
||||
}
|
||||
return contractorVo;
|
||||
}
|
||||
|
||||
@ -323,9 +327,9 @@ public class SubContractorServiceImpl extends ServiceImpl<SubContractorMapper, S
|
||||
return lqw;
|
||||
}
|
||||
// 从对象中取值
|
||||
Long id = req.getId();
|
||||
String name = req.getName();
|
||||
Long projectId = req.getProjectId();
|
||||
Long supplierId = req.getSupplierId();
|
||||
String principal = req.getPrincipal();
|
||||
String principalPhone = req.getPrincipalPhone();
|
||||
String custodian = req.getCustodian();
|
||||
@ -340,7 +344,7 @@ public class SubContractorServiceImpl extends ServiceImpl<SubContractorMapper, S
|
||||
lqw.like(StringUtils.isNotBlank(custodianPhone), SubContractor::getCustodianPhone, custodianPhone);
|
||||
lqw.like(StringUtils.isNotBlank(remark), SubContractor::getRemark, remark);
|
||||
// 精确查询
|
||||
lqw.eq(ObjectUtils.isNotEmpty(id), SubContractor::getId, id);
|
||||
lqw.eq(ObjectUtils.isNotEmpty(supplierId), SubContractor::getSupplierId, supplierId);
|
||||
lqw.eq(ObjectUtils.isNotEmpty(projectId), SubContractor::getProjectId, projectId);
|
||||
lqw.eq(StringUtils.isNotBlank(contractorType), SubContractor::getContractorType, contractorType);
|
||||
return lqw;
|
||||
|
@ -1,17 +1,10 @@
|
||||
package org.dromara.tender.domain;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
import org.dromara.common.core.validate.EditGroup;
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
|
Reference in New Issue
Block a user