Browse Source

同一组织下,部门名称唯一

dev
yinzuomei 2 years ago
parent
commit
73d65e2eb9
  1. 12
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/DepartmentController.java
  2. 5
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/DepartmentServiceImpl.java

12
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/DepartmentController.java

@ -14,9 +14,11 @@ import com.epmet.commons.tools.utils.FileUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.constants.ImportTaskConstants;
import com.epmet.dto.CustomerAgencyDTO;
import com.epmet.dto.form.*;
import com.epmet.dto.result.*;
import com.epmet.feign.EpmetCommonServiceOpenFeignClient;
import com.epmet.service.CustomerAgencyService;
import com.epmet.service.CustomerStaffAgencyService;
import com.epmet.service.DepartmentService;
import lombok.extern.slf4j.Slf4j;
@ -52,6 +54,8 @@ public class DepartmentController implements ResultDataResolver {
private CustomerStaffAgencyService customerStaffAgencyService;
@Autowired
private EpmetCommonServiceOpenFeignClient commonServiceOpenFeignClient;
@Autowired
private CustomerAgencyService customerAgencyService;
/**
* 添加部门人员
@ -253,7 +257,12 @@ public class DepartmentController implements ResultDataResolver {
* @return
*/
@PostMapping("yantai/import")
public Result importExcel(@RequestParam("agencyId")String agencyId, @RequestPart("file") MultipartFile file) {
public Result importExcel(@RequestParam(value = "agencyId",required = true)String agencyId, @RequestPart("file") MultipartFile file) {
CustomerAgencyDTO customerAgencyDTO=customerAgencyService.get(agencyId);
if (null == customerAgencyDTO) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "组织不存在,agencyId" + agencyId, "只有组织才可以导入部门");
}
// 1.暂存文件
String originalFilename = file.getOriginalFilename();
String extName = originalFilename.substring(originalFilename.lastIndexOf("."));
@ -293,7 +302,6 @@ public class DepartmentController implements ResultDataResolver {
EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),
"excel导入部门错误",
"部门导入失败");
// 3.执行导入
departmentService.execAsyncExcelImport(fileSavePath, rstData.getTaskId(),agencyId,originalFilename);
return new Result();

5
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/DepartmentServiceImpl.java

@ -119,6 +119,7 @@ public class DepartmentServiceImpl implements DepartmentService {
@Override
@Transactional(rollbackFor = Exception.class)
public Result<AddDepartmentResultDTO> addDepartment(AddDepartmentFormDTO formDTO) {
//同一组织下部门名称唯一
SpringContextUtils.getBean(CustomerDepartmentService.class).checkUnqiueName(formDTO.getAgencyId(),formDTO.getDepartmentName(),null);
Result<AddDepartmentResultDTO> result = new Result<AddDepartmentResultDTO>();
AddDepartmentResultDTO addDepartmentResultDTO = new AddDepartmentResultDTO();
@ -153,6 +154,7 @@ public class DepartmentServiceImpl implements DepartmentService {
@Transactional(rollbackFor = Exception.class)
public Result editDepartment(EditDepartmentFormDTO formDTO) {
CustomerDepartmentEntity origin=customerDepartmentDao.selectById(formDTO.getDepartmentId());
//同一组织下部门名称唯一
SpringContextUtils.getBean(CustomerDepartmentService.class).checkUnqiueName(origin.getAgencyId(),formDTO.getDepartmentName(),formDTO.getDepartmentId());
Result result = new Result();
CustomerDepartmentEntity entity = ConvertUtils.sourceToTarget(formDTO, CustomerDepartmentEntity.class);
@ -574,9 +576,6 @@ public class DepartmentServiceImpl implements DepartmentService {
@Override
public void execAsyncExcelImport(Path filePath, String importTaskId,String agencyId,String originalFilename) {
CustomerAgencyEntity agencyEntity = customerAgencyDao.selectById(agencyId);
if (null == agencyEntity) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "组织不存在,agencyId" + agencyId, "只有组织才可以导入部门");
}
try {
DeptExcelImportListener listener = new DeptExcelImportListener(EpmetRequestHolder.getLoginUserCustomerId(),
EpmetRequestHolder.getLoginUserId(),

Loading…
Cancel
Save