diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/common/handler/GlobalResponseHandler.java b/pmapi/src/main/java/com/ningdatech/pmapi/common/handler/GlobalResponseHandler.java index 66c5f0f..4bae14f 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/common/handler/GlobalResponseHandler.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/common/handler/GlobalResponseHandler.java @@ -27,7 +27,8 @@ import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice; "com.ningdatech.pmapi.expert.controller", "com.ningdatech.pmapi.sms.controller", "com.ningdatech.pmapi.workbench.controller", - "com.ningdatech.pmapi.ding.controller" + "com.ningdatech.pmapi.ding.controller", + "com.ningdatech.pmapi.filemanage.controller" }) public class GlobalResponseHandler implements ResponseBodyAdvice { diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/ding/controller/DingInfoPullController.java b/pmapi/src/main/java/com/ningdatech/pmapi/ding/controller/DingInfoPullController.java index 09d1102..5e028c9 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/ding/controller/DingInfoPullController.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/ding/controller/DingInfoPullController.java @@ -4,9 +4,7 @@ import com.ningdatech.pmapi.ding.task.EmployeeBatchGetTask; import com.ningdatech.pmapi.ding.task.GovBusinessStripsTask; import com.ningdatech.pmapi.ding.task.OrganizationBatchGetTask; import lombok.RequiredArgsConstructor; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; /** *

@@ -41,4 +39,8 @@ public class DingInfoPullController { organizationBatchGetTask.batchGetOrganizationTask(); } + @GetMapping("/employee/{regionCode}") + public void employeeBatchGetByRegionCode(@PathVariable String regionCode) { + employeeBatchGetTask.batchGetEmployeeTaskByRegionCode(regionCode); + } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/ding/task/EmployeeBatchGetTask.java b/pmapi/src/main/java/com/ningdatech/pmapi/ding/task/EmployeeBatchGetTask.java index ef2d53f..de061ae 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/ding/task/EmployeeBatchGetTask.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/ding/task/EmployeeBatchGetTask.java @@ -194,7 +194,7 @@ public class EmployeeBatchGetTask { dingEmployeeInfoSaveRecordList = dingEmployeeInfoSaveRecordList.stream() .filter(r -> "true".equals(r.getMainJob()) && "A".equals(r.getEmpStatus()) - && StringUtils.isNotBlank(r.getOrganizationCode()) + && StringUtils.isNotBlank(r.getEmpPosUnitCode()) && StringUtils.isNotBlank(r.getEmployeeCode()) ).collect(Collectors.toList()); @@ -203,16 +203,19 @@ public class EmployeeBatchGetTask { List saveList = new ArrayList<>(); for (DingEmployeeInfo dingEmployeeInfo : dingEmployeeInfoSaveRecordList) { - if (uniqueKeySet.add(dingEmployeeInfo.getEmployeeCode() + dingEmployeeInfo.getOrganizationCode())) { + if (uniqueKeySet.add(dingEmployeeInfo.getEmployeeCode() + dingEmployeeInfo.getEmpPosUnitCode())) { saveList.add(dingEmployeeInfo); } } + List organizations = iDingOrganizationService.list(); + Map organizationMap = organizations.stream().collect(Collectors.toMap(DingOrganization::getOrganizationCode, o -> o)); + for (DingEmployeeInfo dingEmployeeInfo : saveList) { String employeeCode = dingEmployeeInfo.getEmployeeCode(); DingEmployeeInfo employeeInfo = iDingEmployeeInfoService.getOne(Wrappers.lambdaQuery(DingEmployeeInfo.class) - .eq(DingEmployeeInfo::getOrganizationCode, dingEmployeeInfo.getOrganizationCode()) + .eq(DingEmployeeInfo::getEmpPosUnitCode, dingEmployeeInfo.getEmpPosUnitCode()) .eq(DingEmployeeInfo::getEmployeeCode, employeeCode)); if (Objects.isNull(employeeInfo)) { iDingEmployeeInfoService.save(dingEmployeeInfo); @@ -220,11 +223,11 @@ public class EmployeeBatchGetTask { dingEmployeeInfo.setId(employeeInfo.getId()); iDingEmployeeInfoService.saveOrUpdate(dingEmployeeInfo); } - generateOrUpdateUserInfo(dingEmployeeInfo); + generateOrUpdateUserInfo(dingEmployeeInfo,organizationMap); } } - public void generateOrUpdateUserInfo(DingEmployeeInfo dingEmployeeInfo) { + public void generateOrUpdateUserInfo(DingEmployeeInfo dingEmployeeInfo,Map organizationMap) { String employeeCode = dingEmployeeInfo.getEmployeeCode(); UserInfo userInfo = iUserInfoService.getOne(Wrappers.lambdaQuery(UserInfo.class) .eq(UserInfo::getEmployeeCode, employeeCode)); @@ -239,11 +242,98 @@ public class EmployeeBatchGetTask { .updateBy(-1L) .createOn(LocalDateTime.now()) .updateOn(LocalDateTime.now()) + .empPosUnitCode(dingEmployeeInfo.getEmpPosUnitCode()) .build(); + if(StringUtils.isNotBlank(userInfo.getEmpPosUnitCode()) && organizationMap.containsKey(userInfo.getEmpPosUnitCode())){ + DingOrganization dingOrganization = organizationMap.get(userInfo.getEmpPosUnitCode()); + userInfo.setEmpPosUnitName(dingOrganization.getOrganizationName()); + userInfo.setRegionCode(dingOrganization.getDivisionCode()); + } iUserInfoService.save(userInfo); } } + /** + * 按区域 来更新员工 + * @param regionCode + */ + public void batchGetEmployeeTaskByRegionCode(String regionCode) { + List units = iDingOrganizationService.list(Wrappers.lambdaQuery(DingOrganization.class) + .eq(DingOrganization::getTypeCode, "GOV_UNIT") + .eq(DingOrganization::getDivisionCode, regionCode)); + + + log.info("所有地区 {} 待更新员工的单位数:{}",regionCode,units.size()); + if (CollUtil.isNotEmpty(units)) { + //记录任务 单位数 + Integer index = 0; + for (DingOrganization dingOrganization : units) { + log.info("当前单位:{},下标数,{}",dingOrganization.getOrganizationName(),index); + index++; + List allOrganizationEmployeePositionList = new ArrayList<>(); + String organizationCode = dingOrganization.getOrganizationCode(); + PageOrganizationEmployeePositionsQuery query = new PageOrganizationEmployeePositionsQuery(); + query.setEmployeeStatus("A"); + query.setOrganizationCode(organizationCode); + query.setReturnTotalSize(true); + query.setTenantId(zwddIntegrationProperties.getTenantId()); + int pageNo = 1; + query.setPageNo(pageNo); + query.setPageSize(PAGE_SIZE); + + // 查询组织下 用户信息 + GenericResult> firstPageGenericResult = zwddClient.pageOrganizationEmployeePositions(query); + Page data = firstPageGenericResult.getData(); + if (Objects.isNull(data)){ + log.info("响应为空:{}",organizationCode); + continue; + } + if (CollUtil.isNotEmpty(data.getData())) { + allOrganizationEmployeePositionList.addAll(data.getData()); + } + Long totalSize = data.getTotalSize(); + + log.info("dingOrganization :{}", JSON.toJSONString(dingOrganization)); + + log.info("totalSize :{},{}", totalSize,dingOrganization.getOrganizationName()); + if (totalSize > PAGE_SIZE) { + if (totalSize > MAX_SIZE) { + //超过1万 按1万的处理 + totalSize = MAX_SIZE.longValue(); + } + + int restPageNo = totalSize % PAGE_SIZE > 0 ? 1 : 0; + int maxPageNo = (int) Math.ceil(totalSize / PAGE_SIZE) + restPageNo; + for (pageNo = 2; pageNo <= maxPageNo; pageNo++) { + query.setPageNo(pageNo); + GenericResult> pageGenericResult = zwddClient.pageOrganizationEmployeePositions(query); +// log.info("pageGenericResult :{}", JSON.toJSONString(pageGenericResult)); + if(pageGenericResult.isSuccess()){ + allOrganizationEmployeePositionList.addAll(pageGenericResult.getData().getData()); + }else{ + log.error(pageGenericResult.getMsg()); + } + } + } + + // 批量查询 成员的accountId + List dingEmployeeInfoSaveRecordList = new ArrayList<>(); + if (allOrganizationEmployeePositionList.size() <= GROUP_SIZE) { + log.info("assemblerAccountId :{}", allOrganizationEmployeePositionList.size()); + assemblerAccountId(allOrganizationEmployeePositionList, dingEmployeeInfoSaveRecordList); + } else { + log.info("assemblerAccountId :{}", allOrganizationEmployeePositionList.size()); + List> split = Lists.partition(allOrganizationEmployeePositionList, GROUP_SIZE); + for (List segment : split) { + assemblerAccountId(segment, dingEmployeeInfoSaveRecordList); + } + } + // 批量保存用户信息 + saveBatch(dingEmployeeInfoSaveRecordList); + } + } + } + // if (saveList.size() <= GROUP_SIZE) { // iDingEmployeeInfoService.saveBatch(saveList); // } else { diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/controller/DocumentationController.java b/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/controller/DocumentationController.java index ff762d1..3bf7fa9 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/controller/DocumentationController.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/controller/DocumentationController.java @@ -2,11 +2,17 @@ package com.ningdatech.pmapi.filemanage.controller; import com.ningdatech.basic.model.PageVo; import com.ningdatech.pmapi.filemanage.manage.DocumentationManage; +import com.ningdatech.pmapi.filemanage.model.dto.DocumentationGroupSaveDTO; +import com.ningdatech.pmapi.filemanage.model.dto.DocumentationSaveDTO; import com.ningdatech.pmapi.filemanage.model.param.DocumentationListParam; +import com.ningdatech.pmapi.filemanage.model.vo.DocumentationGroupVO; import com.ningdatech.pmapi.filemanage.model.vo.DocumentationVO; import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; import lombok.AllArgsConstructor; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; +import java.util.List; /** * @Classname DocumentationController @@ -18,12 +24,50 @@ import org.springframework.web.bind.annotation.*; @AllArgsConstructor @Api(tags = "档案管理-资料文档控制器") @RequestMapping("/api/v1/file-manage/documentation") +@Validated public class DocumentationController { private final DocumentationManage documentationManage; + @GetMapping("/group/list") + @ApiOperation(value = "分组列表", notes = "分组列表") + public List groupList(){ + return documentationManage.groupList(); + } + + @PostMapping("/group/add") + @ApiOperation(value = "分组添加", notes = "分组添加") + public String addGroup(@Validated @RequestBody DocumentationGroupSaveDTO dto){ + return documentationManage.addGroup(dto); + } + + @PostMapping("/group/delete/{id}") + @ApiOperation(value = "分组删除", notes = "分组删除") + public String deleteGroup(@PathVariable Long id){ + return documentationManage.deleteGroup(id); + } + @GetMapping("/list") + @ApiOperation(value = "文档列表", notes = "文档列表") public PageVo list(@ModelAttribute DocumentationListParam param){ return documentationManage.list(param); } + + @GetMapping("/detail/{id}") + @ApiOperation(value = "文档详情", notes = "文档详情") + public DocumentationVO detail(@PathVariable Long id){ + return documentationManage.detail(id); + } + + @PostMapping("/add") + @ApiOperation(value = "文档添加", notes = "文档添加") + public String addDoc(@Validated @RequestBody DocumentationSaveDTO dto){ + return documentationManage.addDoc(dto); + } + + @PostMapping("/delete/{id}") + @ApiOperation(value = "文档删除", notes = "文档删除") + public String deleteDoc(@PathVariable Long id){ + return documentationManage.deleteDoc(id); + } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/controller/ProjectFileController.java b/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/controller/ProjectFileController.java new file mode 100644 index 0000000..0605b44 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/controller/ProjectFileController.java @@ -0,0 +1,46 @@ +package com.ningdatech.pmapi.filemanage.controller; + +import com.ningdatech.basic.model.PageVo; +import com.ningdatech.pmapi.filemanage.manage.ProjectFileManage; +import com.ningdatech.pmapi.filemanage.model.param.ProjectFileListParam; +import com.ningdatech.pmapi.filemanage.model.vo.ProjectFileListVO; +import com.ningdatech.pmapi.filemanage.model.vo.ProjectFileVO; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +/** + * @Classname ProjectFileController + * @Description + * @Date 2023/6/6 15:48 + * @Author PoffyZhang + */ +@RestController +@AllArgsConstructor +@Api(tags = "档案管理-项目档案") +@RequestMapping("/api/v1/file-manage/project-file") +@Validated +public class ProjectFileController { + + private final ProjectFileManage projectFileManage; + + @GetMapping("/list") + @ApiOperation(value = "档案列表", notes = "档案列表") + public PageVo list(@ModelAttribute ProjectFileListParam param){ + return projectFileManage.list(param); + } + + @GetMapping("/{projectId}") + @ApiOperation(value = "档案详情", notes = "档案详情") + public ProjectFileVO file(@PathVariable Long projectId){ + return projectFileManage.file(projectId); + } + + @PostMapping("/want-read/{projectId}") + @ApiOperation(value = "申请借阅", notes = "申请借阅") + public String wantRead(@PathVariable Long projectId){ + return projectFileManage.wantRead(projectId); + } +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/manage/DocumentationManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/manage/DocumentationManage.java index fa9f83a..5b95a09 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/manage/DocumentationManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/manage/DocumentationManage.java @@ -3,15 +3,28 @@ package com.ningdatech.pmapi.filemanage.manage; import cn.hutool.core.bean.BeanUtil; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ningdatech.basic.exception.BizException; +import com.ningdatech.basic.function.VUtils; import com.ningdatech.basic.model.PageVo; +import com.ningdatech.file.entity.File; +import com.ningdatech.file.service.FileService; +import com.ningdatech.pmapi.filemanage.model.dto.DocumentationGroupSaveDTO; +import com.ningdatech.pmapi.filemanage.model.dto.DocumentationSaveDTO; import com.ningdatech.pmapi.filemanage.model.entity.Documentation; +import com.ningdatech.pmapi.filemanage.model.entity.DocumentationGroup; import com.ningdatech.pmapi.filemanage.model.param.DocumentationListParam; +import com.ningdatech.pmapi.filemanage.model.vo.DocumentationGroupVO; import com.ningdatech.pmapi.filemanage.model.vo.DocumentationVO; +import com.ningdatech.pmapi.filemanage.service.IDocumentationGroupService; import com.ningdatech.pmapi.filemanage.service.IDocumentationService; +import com.ningdatech.pmapi.user.security.auth.model.UserInfoDetails; +import com.ningdatech.pmapi.user.util.LoginUserUtil; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; +import java.time.LocalDateTime; import java.util.List; import java.util.Objects; import java.util.stream.Collectors; @@ -29,6 +42,20 @@ public class DocumentationManage { private final IDocumentationService documentationService; + private final IDocumentationGroupService documentationGroupService; + + private final FileService fileService; + + /** + * + * @return + */ + public List groupList() { + List list = documentationGroupService.list(); + + return list.stream().map(g -> BeanUtil.copyProperties(g,DocumentationGroupVO.class)).collect(Collectors.toList()); + } + /** * 文档列表 * @param param @@ -49,4 +76,98 @@ public class DocumentationManage { return PageVo.of(vos,page.getTotal()); } + + /** + * 增加分组 + * @param dto + * @return + */ + public String addGroup(DocumentationGroupSaveDTO dto) { + UserInfoDetails user = LoginUserUtil.loginUserDetail(); + if(documentationGroupService.count(Wrappers.lambdaQuery(DocumentationGroup.class) + .eq(DocumentationGroup::getName,dto.getName())) > 0){ + throw new BizException("此分组名 已经存在"); + } + + DocumentationGroup documentationGroup = BeanUtil.copyProperties(dto, DocumentationGroup.class); + documentationGroup.setCreateBy(user.getRealName()); + documentationGroup.setCreateOn(LocalDateTime.now()); + if(documentationGroupService.save(documentationGroup)){ + return "添加成功"; + } + return "添加失败"; + } + + /** + * 删除分组 同时删除文档 + * @param id + * @return + */ + @Transactional + public String deleteGroup(Long id) { + DocumentationGroup group = documentationGroupService.getById(id); + VUtils.isTrue(Objects.isNull(group)).throwMessage("该分组不存在!"); + + // + documentationService.remove(Wrappers.lambdaQuery(Documentation.class) + .eq(Documentation::getGroupId, id)); + documentationGroupService.removeById(id); + + return "删除成功"; + } + + /** + * 上传文档 + * @param dto + * @return + */ + public String addDoc(DocumentationSaveDTO dto) { + UserInfoDetails user = LoginUserUtil.loginUserDetail(); + + Long fileId = dto.getFileId(); + File file = fileService.getById(fileId); + + VUtils.isTrue(Objects.isNull(file)).throwMessage("该文件不存在!"); + + DocumentationGroup group = documentationGroupService.getById(dto.getGroupId()); + + VUtils.isTrue(Objects.isNull(group)).throwMessage("分组不存在!"); + + Documentation documentation = new Documentation(); + documentation.setCreateBy(user.getRealName()); + documentation.setCreateOn(LocalDateTime.now()); + documentation.setSize(Objects.nonNull(file.getSize()) ? file.getSize()/1000L : 0L); + documentation.setFileId(fileId); + documentation.setGroupId(dto.getGroupId()); + documentation.setFileName(file.getOriginalFileName()); + if(documentationService.save(documentation)){ + documentation.setSort(documentation.getId().intValue()); + documentationService.updateById(documentation); + } + + return "添加成功"; + } + + /** + * 删除文档 + * @param id + * @return + */ + public String deleteDoc(Long id) { + Documentation doc = documentationService.getById(id); + VUtils.isTrue(Objects.isNull(doc)).throwMessage("该文档不存在!"); + + if(documentationService.removeById(id)){ + return "删除成功"; + } + return "删除失败"; + } + + public DocumentationVO detail(Long id) { + Documentation doc = documentationService.getById(id); + if(Objects.isNull(doc)){ + return null; + } + return BeanUtil.copyProperties(doc,DocumentationVO.class); + } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/manage/ProjectFileManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/manage/ProjectFileManage.java new file mode 100644 index 0000000..bd8211b --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/manage/ProjectFileManage.java @@ -0,0 +1,61 @@ +package com.ningdatech.pmapi.filemanage.manage; + +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ningdatech.basic.model.PageVo; +import com.ningdatech.pmapi.filemanage.model.param.ProjectFileListParam; +import com.ningdatech.pmapi.filemanage.model.vo.ProjectFileListVO; +import com.ningdatech.pmapi.filemanage.model.vo.ProjectFileVO; +import com.ningdatech.pmapi.projectlib.model.entity.Project; +import com.ningdatech.pmapi.projectlib.service.IProjectService; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Component; + +import java.util.List; +import java.util.stream.Collectors; + +/** + * @Classname ProjectFileManage + * @Description + * @Date 2023/6/6 16:04 + * @Author PoffyZhang + */ +@Component +@AllArgsConstructor +@Slf4j +public class ProjectFileManage { + + private final IProjectService projectService; + + public PageVo list(ProjectFileListParam param) { + Page page = param.page(); + projectService.page(page,Wrappers.lambdaQuery(Project.class) + .like(StringUtils.isNotBlank(param.getProjectName()),Project::getProjectName,param.getProjectName()) + .like(StringUtils.isNotBlank(param.getBuildOrgName()),Project::getBuildOrgName,param.getBuildOrgName()) + .orderByDesc(Project::getUpdateOn)); + + if(0L == page.getTotal()){ + return PageVo.empty(); + } + List vos = page.getRecords().stream().map(p -> { + ProjectFileListVO vo = new ProjectFileListVO(); + vo.setId(p.getId()); + vo.setCanRead(Boolean.TRUE); + vo.setBuildOrgName(p.getBuildOrgName()); + vo.setPojectCode(p.getProjectCode()); + vo.setProjectName(p.getProjectName()); + return vo; + }).collect(Collectors.toList()); + return PageVo.of(vos,page.getTotal()); + } + + public ProjectFileVO file(Long projectId) { + return null; + } + + public String wantRead(Long projectId) { + return "申请成功"; + } +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/mapper/DocumentationGroupMapper.java b/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/mapper/DocumentationGroupMapper.java new file mode 100644 index 0000000..bdf415e --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/mapper/DocumentationGroupMapper.java @@ -0,0 +1,16 @@ +package com.ningdatech.pmapi.filemanage.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ningdatech.pmapi.filemanage.model.entity.DocumentationGroup; + +/** + *

+ * Mapper 接口 + *

+ * + * @author CMM + * @since 2023-02-27 + */ +public interface DocumentationGroupMapper extends BaseMapper { + +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/mapper/DocumentationGroupMapper.xml b/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/mapper/DocumentationGroupMapper.xml new file mode 100644 index 0000000..2d4547b --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/mapper/DocumentationGroupMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/model/dto/DocumentationGroupSaveDTO.java b/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/model/dto/DocumentationGroupSaveDTO.java new file mode 100644 index 0000000..e0763fa --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/model/dto/DocumentationGroupSaveDTO.java @@ -0,0 +1,22 @@ +package com.ningdatech.pmapi.filemanage.model.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @Classname Documentation + * @Description + * @Date 2023/6/6 14:41 + * @Author PoffyZhang + */ +@Data +@ApiModel(value = "DocumentationGroupSaveDTO", description = "DocumentationGroupSaveDTO") +public class DocumentationGroupSaveDTO { + + @ApiModelProperty("分组名") + private String name; + + @ApiModelProperty("排序") + private Integer sort; +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/model/dto/DocumentationSaveDTO.java b/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/model/dto/DocumentationSaveDTO.java new file mode 100644 index 0000000..2f66359 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/model/dto/DocumentationSaveDTO.java @@ -0,0 +1,29 @@ +package com.ningdatech.pmapi.filemanage.model.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotNull; + +/** + * @Classname Documentation + * @Description + * @Date 2023/6/6 14:41 + * @Author PoffyZhang + */ +@Data +@ApiModel(value = "DocumentationSaveDTO", description = "DocumentationSaveDTO") +public class DocumentationSaveDTO { + + @ApiModelProperty("文档分类ID") + @NotNull(message = "请传分组ID") + private Long groupId; + + @ApiModelProperty("文档ID") + @NotNull(message = "请传文档ID") + private Long fileId; + + @ApiModelProperty("排序") + private Integer sort; +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/model/entity/Documentation.java b/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/model/entity/Documentation.java index c837051..5162484 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/model/entity/Documentation.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/model/entity/Documentation.java @@ -28,10 +28,10 @@ public class Documentation { private String fileName; @ApiModelProperty("上传人") - private String creatBy; + private String createBy; @ApiModelProperty("上传时间") - private LocalDateTime creatOn; + private LocalDateTime createOn; @ApiModelProperty("文档大小 kb") private Long size; @@ -39,6 +39,9 @@ public class Documentation { @ApiModelProperty("文档分类ID") private Long groupId; + @ApiModelProperty("文档ID") + private Long fileId; + @ApiModelProperty("排序") private Integer sort; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/model/entity/DocumentationGroup.java b/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/model/entity/DocumentationGroup.java index 466721f..f76cf45 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/model/entity/DocumentationGroup.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/model/entity/DocumentationGroup.java @@ -25,10 +25,10 @@ public class DocumentationGroup { private Long id; @ApiModelProperty("上传人") - private String creatBy; + private String createBy; @ApiModelProperty("上传时间") - private LocalDateTime creatOn; + private LocalDateTime createOn; @ApiModelProperty("分组名") private String name; diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/model/param/ProjectFileListParam.java b/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/model/param/ProjectFileListParam.java new file mode 100644 index 0000000..ea87f3f --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/model/param/ProjectFileListParam.java @@ -0,0 +1,22 @@ +package com.ningdatech.pmapi.filemanage.model.param; + +import com.ningdatech.basic.model.PagePo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @Classname ProjectFileListParam + * @Description + * @Date 2023/6/6 16:06 + * @Author PoffyZhang + */ +@Data +public class ProjectFileListParam extends PagePo { + + @ApiModelProperty("项目名称") + private String projectName; + + @ApiModelProperty("项目单位") + private String buildOrgName; + +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/model/vo/DocumentationGroupVO.java b/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/model/vo/DocumentationGroupVO.java new file mode 100644 index 0000000..a46e229 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/model/vo/DocumentationGroupVO.java @@ -0,0 +1,33 @@ +package com.ningdatech.pmapi.filemanage.model.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.time.LocalDateTime; + +/** + * @Classname Documentation + * @Description + * @Date 2023/6/6 14:41 + * @Author PoffyZhang + */ +@Data +@ApiModel(value = "nd_documentation_group", description = "资料文档分组") +public class DocumentationGroupVO { + + @ApiModelProperty("主键") + private Long id; + + @ApiModelProperty("上传人") + private String createBy; + + @ApiModelProperty("上传时间") + private LocalDateTime createOn; + + @ApiModelProperty("分组名") + private String name; + + @ApiModelProperty("排序") + private Integer sort; +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/model/vo/DocumentationVO.java b/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/model/vo/DocumentationVO.java index 97d7a8b..1f21de0 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/model/vo/DocumentationVO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/model/vo/DocumentationVO.java @@ -23,10 +23,10 @@ public class DocumentationVO { private String fileName; @ApiModelProperty("上传人") - private String creatBy; + private String createBy; @ApiModelProperty("上传时间") - private LocalDateTime creatOn; + private LocalDateTime createOn; @ApiModelProperty("文档大小 kb") private Long size; diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/model/vo/ProjectFileListVO.java b/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/model/vo/ProjectFileListVO.java new file mode 100644 index 0000000..f7b2657 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/model/vo/ProjectFileListVO.java @@ -0,0 +1,36 @@ +package com.ningdatech.pmapi.filemanage.model.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.time.LocalDateTime; + +/** + * @Classname Documentation + * @Description + * @Date 2023/6/6 14:41 + * @Author PoffyZhang + */ +@Data +@ApiModel(value = "ProjectFileListVO", description = "资料文档") +public class ProjectFileListVO { + + @ApiModelProperty("项目ID") + private Long id; + + @ApiModelProperty("项目名称") + private String projectName; + + @ApiModelProperty("项目单位") + private String buildOrgName; + + @ApiModelProperty("项目编号") + private String pojectCode; + + @ApiModelProperty("是否可阅") + private Boolean canRead = Boolean.FALSE; + + @ApiModelProperty("最后修改时间") + private LocalDateTime updateOn; +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/model/vo/ProjectFileVO.java b/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/model/vo/ProjectFileVO.java new file mode 100644 index 0000000..c49c8cf --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/model/vo/ProjectFileVO.java @@ -0,0 +1,36 @@ +package com.ningdatech.pmapi.filemanage.model.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.time.LocalDateTime; + +/** + * @Classname ProjectFileVO + * @Description + * @Date 2023/6/6 14:41 + * @Author PoffyZhang + */ +@Data +@ApiModel(value = "ProjectFileVO", description = "项目档案") +public class ProjectFileVO { + + @ApiModelProperty("项目ID") + private Long id; + + @ApiModelProperty("项目名称") + private String projectName; + + @ApiModelProperty("项目单位") + private String buildOrgName; + + @ApiModelProperty("项目编号") + private String pojectCode; + + @ApiModelProperty("是否可阅") + private Boolean canRead = Boolean.FALSE; + + @ApiModelProperty("最后修改时间") + private LocalDateTime updateOn; +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/service/IDocumentationGroupService.java b/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/service/IDocumentationGroupService.java new file mode 100644 index 0000000..61a0786 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/service/IDocumentationGroupService.java @@ -0,0 +1,9 @@ +package com.ningdatech.pmapi.filemanage.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ningdatech.pmapi.filemanage.model.entity.DocumentationGroup; + +public interface IDocumentationGroupService extends IService { + + +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/service/impl/DocumentationGroupServiceImpl.java b/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/service/impl/DocumentationGroupServiceImpl.java new file mode 100644 index 0000000..35c59b6 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/service/impl/DocumentationGroupServiceImpl.java @@ -0,0 +1,20 @@ +package com.ningdatech.pmapi.filemanage.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ningdatech.pmapi.filemanage.mapper.DocumentationGroupMapper; +import com.ningdatech.pmapi.filemanage.model.entity.DocumentationGroup; +import com.ningdatech.pmapi.filemanage.service.IDocumentationGroupService; +import org.springframework.stereotype.Service; + +/** + *

+ * 服务实现类 + *

+ * + * @author Poffy + * @since 2023-02-13 + */ +@Service +public class DocumentationGroupServiceImpl extends ServiceImpl implements IDocumentationGroupService { + +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/sms/helper/VerifyCodeCheckHelper.java b/pmapi/src/main/java/com/ningdatech/pmapi/sms/helper/VerifyCodeCheckHelper.java index c1a5034..ac26416 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/sms/helper/VerifyCodeCheckHelper.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/sms/helper/VerifyCodeCheckHelper.java @@ -40,4 +40,5 @@ public class VerifyCodeCheckHelper { return verificationCode.trim().equals(cache.getCode()); } + } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/user/entity/UserInfo.java b/pmapi/src/main/java/com/ningdatech/pmapi/user/entity/UserInfo.java index ee4b650..1c0758d 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/user/entity/UserInfo.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/user/entity/UserInfo.java @@ -45,6 +45,9 @@ public class UserInfo implements Serializable { private String regionCode; + private String empPosUnitCode; + private String empPosUnitName; + @TableField(fill = FieldFill.INSERT) private LocalDateTime createOn; diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/user/manage/UserInfoManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/user/manage/UserInfoManage.java index f69dd35..932a2dd 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/user/manage/UserInfoManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/user/manage/UserInfoManage.java @@ -63,6 +63,7 @@ public class UserInfoManage { String phoneNo = req.getPhoneNo(); String orgCode = req.getOrgCode(); String name = req.getName(); + String orgName = req.getOrgName(); Long regionId = req.getRegionId(); List userIdList = getRoleCompliantUserIdList(req.getUserRoleList()); @@ -71,19 +72,14 @@ public class UserInfoManage { pageVo.setTotal(0L); return pageVo; } - List compliantOrgEmpCodeList = getCompliantOrgEmpCodeList(req.getOrgName(), orgCode); - if (compliantOrgEmpCodeList != null && compliantOrgEmpCodeList.size() == 0) { - pageVo.setRecords(new ArrayList<>()); - pageVo.setTotal(0L); - return pageVo; - } LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(UserInfo.class) .like(StringUtils.isNotBlank(phoneNo), UserInfo::getMobile, phoneNo) .like(StringUtils.isNotBlank(name), UserInfo::getRealName, name) .in(Objects.nonNull(userIdList), UserInfo::getId, userIdList) .eq(Objects.nonNull(regionId), UserInfo::getRegionCode,regionId) - .in(Objects.nonNull(compliantOrgEmpCodeList), UserInfo::getEmployeeCode, compliantOrgEmpCodeList) + .like(StringUtils.isNotBlank(orgName), UserInfo::getEmpPosUnitName, orgName) + .eq(StringUtils.isNotBlank(orgCode), UserInfo::getEmpPosUnitCode, orgCode) .orderByDesc(UserInfo::getUpdateOn); Page page = iUserInfoService.page(new Page<>(req.getPageNumber(), req.getPageSize()), wrapper); @@ -136,7 +132,7 @@ public class UserInfoManage { if (StringUtils.isNotBlank(orgName)) { List dingOrganizationList = iDingOrganizationService.list(Wrappers.lambdaQuery(DingOrganization.class) .like(DingOrganization::getOrganizationName, orgName) - .notIn(DingOrganization::getTypeCode, "GOV_INTERNAL_INSTITUTION") + .eq(DingOrganization::getTypeCode, "GOV_UNIT") ); List compliantOrgNameCodeList = dingOrganizationList.stream() diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/credential/CredentialAuthProvider.java b/pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/credential/CredentialAuthProvider.java index ed77a20..b5e76dc 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/credential/CredentialAuthProvider.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/credential/CredentialAuthProvider.java @@ -1,8 +1,11 @@ package com.ningdatech.pmapi.user.security.auth.credential; import com.ningdatech.basic.model.GenericResult; +import com.ningdatech.pmapi.sms.constant.VerificationCodeType; +import com.ningdatech.pmapi.sms.helper.VerifyCodeCheckHelper; import com.ningdatech.pmapi.user.constant.LoginTypeEnum; import com.ningdatech.pmapi.user.security.auth.constants.UserDeatilsServiceConstant; +import com.ningdatech.pmapi.user.security.auth.validate.CommonLoginException; import com.ningdatech.zwdd.client.ZwddAuthClient; import org.springframework.security.authentication.AuthenticationProvider; import org.springframework.security.authentication.BadCredentialsException; @@ -27,6 +30,11 @@ public class CredentialAuthProvider implements AuthenticationProvider { private ZwddAuthClient zwddAuthClient; + private Boolean phoneVerifyCodeSkip; + + private VerifyCodeCheckHelper verifyCodeCheckHelper; + + @Override public Authentication authenticate(Authentication authentication) throws AuthenticationException { if (!(authentication instanceof CredentialAuthToken)) { @@ -37,6 +45,7 @@ public class CredentialAuthProvider implements AuthenticationProvider { UserDetails user = null; LoginTypeEnum loginTypeEnum = authenticationToken.getLoginTypeEnum(); + String credentials = (String) authenticationToken.getCredentials(); switch (loginTypeEnum) { case DING_QR_LOGIN: { String code = (String) authenticationToken.getCredentials(); @@ -52,7 +61,13 @@ public class CredentialAuthProvider implements AuthenticationProvider { } break; case PHONE_VERIFICATION_CODE_LOGIN: { - // TODO 校验短信验证码 + if (!phoneVerifyCodeSkip) { + // 校验短信验证码 + boolean verificationResult = verifyCodeCheckHelper.verification(VerificationCodeType.LOGIN, principal, credentials); + if (!verificationResult) { + throw new CommonLoginException("验证码错误"); + } + } user = userDetailsService.loadUserByUsername(principal + UserDeatilsServiceConstant.USER_DETAILS_SERVICE_SEPARATOR + loginTypeEnum.name()); } break; @@ -95,4 +110,12 @@ public class CredentialAuthProvider implements AuthenticationProvider { this.zwddAuthClient = zwddAuthClient; } + public void setVerifyCodeCheckHelper(VerifyCodeCheckHelper verifyCodeCheckHelper) { + this.verifyCodeCheckHelper = verifyCodeCheckHelper; + } + + public void setPhoneVerifyCodeSkip(Boolean phoneVerifyCodeSkip) { + this.phoneVerifyCodeSkip = phoneVerifyCodeSkip; + } + } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/credential/CredentialAuthSecurityConfig.java b/pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/credential/CredentialAuthSecurityConfig.java index 332cfb1..c8a442c 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/credential/CredentialAuthSecurityConfig.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/credential/CredentialAuthSecurityConfig.java @@ -1,9 +1,11 @@ package com.ningdatech.pmapi.user.security.auth.credential; +import com.ningdatech.pmapi.sms.helper.VerifyCodeCheckHelper; import com.ningdatech.pmapi.user.security.auth.AuthProperties; import com.ningdatech.zwdd.client.ZwddAuthClient; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.beans.factory.annotation.Value; import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.config.annotation.SecurityConfigurerAdapter; import org.springframework.security.config.annotation.web.builders.HttpSecurity; @@ -21,6 +23,8 @@ import org.springframework.stereotype.Component; @Component public class CredentialAuthSecurityConfig extends SecurityConfigurerAdapter { + @Value("${login.phone-verify-code.skip:false}") + private Boolean skipLoginVerifyCodeCheck; @Autowired @Qualifier(value = "defaultLoginSuccessHandler") @@ -45,6 +49,9 @@ public class CredentialAuthSecurityConfig @Autowired private ZwddAuthClient zwddAuthClient; + @Autowired + private VerifyCodeCheckHelper verifyCodeCheckHelper; + @Override public void configure(HttpSecurity http) throws Exception { CredentialAuthFilter credentialAuthFilter = @@ -55,11 +62,13 @@ public class CredentialAuthSecurityConfig credentialAuthFilter.setAuthenticationFailureHandler(defaultLoginFailureHandler); CredentialAuthProvider authenticationProvider = new CredentialAuthProvider(); + authenticationProvider.setPhoneVerifyCodeSkip(skipLoginVerifyCodeCheck); authenticationProvider.setUserDetailsService(credentialLoginUserDetailService); // 确保对密码进行加密的encoder和解密的encoder相同 authenticationProvider.setPasswordEncoder(passwordEncoder); // 传入浙政钉client authenticationProvider.setZwddAuthClient(zwddAuthClient); + authenticationProvider.setVerifyCodeCheckHelper(verifyCodeCheckHelper); http.authenticationProvider(authenticationProvider).addFilterAfter(credentialAuthFilter, UsernamePasswordAuthenticationFilter.class); diff --git a/pmapi/src/main/resources/application-dev.yml b/pmapi/src/main/resources/application-dev.yml index cb0c3c5..e95eb4f 100644 --- a/pmapi/src/main/resources/application-dev.yml +++ b/pmapi/src/main/resources/application-dev.yml @@ -210,3 +210,8 @@ irs: api-url: https://bcdsg.zj.gov.cn:8443/restapi/prod/IC33000020220309000004/seal-platform/seal/v1/rest/sign/signPdf hostname: iZbp13nwyvib53j4j1p2xoZ + +login: + phone-verify-code: + skip: true + diff --git a/pmapi/src/main/resources/application-prod.yml b/pmapi/src/main/resources/application-prod.yml index 022c0a3..ea7ba7d 100644 --- a/pmapi/src/main/resources/application-prod.yml +++ b/pmapi/src/main/resources/application-prod.yml @@ -209,4 +209,8 @@ irs: secret-key: bebff29877d4443abd67fc4f8fb335d8 api-url: https://bcdsg.zj.gov.cn:8443/restapi/prod/IC33000020220309000004/seal-platform/seal/v1/rest/sign/signPdf -hostname: iZ6mx01gyeodd80imxd2gbZ \ No newline at end of file +hostname: iZ6mx01gyeodd80imxd2gbZ +login: + phone-verify-code: + skip: true +