Conflicts: pmapi/src/test/java/com/ningdatech/pmapi/projectCollection/ProjectCollectionTest.javamaster
@@ -18,9 +18,12 @@ import io.swagger.annotations.Api; | |||
import io.swagger.annotations.ApiOperation; | |||
import lombok.RequiredArgsConstructor; | |||
import org.springframework.web.bind.annotation.*; | |||
import springfox.documentation.annotations.ApiIgnore; | |||
import javax.servlet.http.HttpServletResponse; | |||
import javax.validation.Valid; | |||
import javax.validation.constraints.NotNull; | |||
import java.io.IOException; | |||
/** | |||
* <p> | |||
@@ -32,13 +35,30 @@ import javax.validation.constraints.NotNull; | |||
*/ | |||
@RestController | |||
@Api(tags = "专家管理相关接口") | |||
@RequestMapping("/api/v1/expert") | |||
@RequestMapping(value = {"/api/v1/expert", "/expert"}) | |||
@RequiredArgsConstructor | |||
public class ExpertController { | |||
private final ExpertManage expertManage; | |||
private final ExpertAdminManage expertAdminManage; | |||
/** | |||
* 生成专家报名临时地址 | |||
* | |||
* @return 生成专家报名临时地址 | |||
*/ | |||
@GetMapping("/getRegistrationUrl") | |||
public String getRegistrationUrl() { | |||
return expertManage.getRegistrationUrl(); | |||
} | |||
@ApiIgnore | |||
@GetMapping("/ephemeral/{uniqueId}/registration") | |||
public void getRegistrationUrl(@PathVariable String uniqueId, HttpServletResponse response) throws IOException { | |||
expertManage.redirectToRegistrationUrl(uniqueId, response); | |||
} | |||
@PostMapping("/registration") | |||
@ApiOperation("社会专家报名") | |||
@WebLog("社会专家报名") | |||
@@ -1,11 +1,15 @@ | |||
package com.ningdatech.pmapi.expert.manage; | |||
import cn.hutool.core.collection.CollUtil; | |||
import cn.hutool.core.util.StrUtil; | |||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||
import com.ningdatech.basic.exception.BizException; | |||
import com.ningdatech.cache.model.cache.CacheKey; | |||
import com.ningdatech.cache.repository.CachePlusOps; | |||
import com.ningdatech.file.entity.vo.result.AttachFileVo; | |||
import com.ningdatech.file.service.FileService; | |||
import com.ningdatech.pmapi.common.model.FileBasicInfo; | |||
import com.ningdatech.pmapi.common.util.BizUtils; | |||
import com.ningdatech.pmapi.expert.assembler.ExpertInfoCmdAssembler; | |||
import com.ningdatech.pmapi.expert.assembler.ExpertUserInfoAssembler; | |||
import com.ningdatech.pmapi.expert.constant.ExpertAccountStatusEnum; | |||
@@ -23,6 +27,7 @@ import com.ningdatech.pmapi.expert.model.req.ExpertUserBasicInfoSubmitRequest; | |||
import com.ningdatech.pmapi.expert.model.vo.ExpertFullInfoVO; | |||
import com.ningdatech.pmapi.expert.service.ExpertInfoService; | |||
import com.ningdatech.pmapi.expert.service.IExpertUserFullInfoService; | |||
import com.ningdatech.pmapi.meeting.entity.config.WebProperties; | |||
import com.ningdatech.pmapi.meta.constant.DictExpertInfoTypeEnum; | |||
import com.ningdatech.pmapi.meta.model.ExpertRegionInfo; | |||
import com.ningdatech.pmapi.sms.constant.VerificationCodeType; | |||
@@ -37,10 +42,16 @@ import com.ningdatech.pmapi.user.entity.enumeration.RoleEnum; | |||
import com.ningdatech.pmapi.user.service.IUserInfoService; | |||
import com.ningdatech.pmapi.user.util.LoginUserUtil; | |||
import lombok.RequiredArgsConstructor; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.apache.commons.collections4.CollectionUtils; | |||
import org.springframework.http.MediaType; | |||
import org.springframework.stereotype.Component; | |||
import org.springframework.transaction.annotation.Transactional; | |||
import javax.servlet.http.HttpServletResponse; | |||
import java.io.IOException; | |||
import java.nio.charset.StandardCharsets; | |||
import java.time.Duration; | |||
import java.time.LocalDateTime; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
@@ -51,7 +62,7 @@ import java.util.stream.Collectors; | |||
* @author liuxinxin | |||
* @date 2023/2/23 上午8:55 | |||
*/ | |||
@Slf4j | |||
@Component | |||
@RequiredArgsConstructor | |||
public class ExpertManage { | |||
@@ -67,6 +78,44 @@ public class ExpertManage { | |||
private final IUserRoleService iUserRoleService; | |||
private final IRoleService iRoleService; | |||
private final VerifyCodeCheckHelper verifyCodeCheckHelper; | |||
private final CachePlusOps cachePlusOps; | |||
private static final Duration REGISTER_EXPIRED_DURATION = Duration.ofDays(3); | |||
private static final Duration REGISTER_GEN_DURATION = Duration.ofMinutes(30); | |||
private static final String RK_REGISTER_UNIQUE_ID = "expert_registration_id:"; | |||
private static final String RK_REGISTER_UNIQUE_ID_LAST = RK_REGISTER_UNIQUE_ID + "last"; | |||
public synchronized String getRegistrationUrl() { | |||
CacheKey lastKey = new CacheKey(RK_REGISTER_UNIQUE_ID_LAST, REGISTER_GEN_DURATION); | |||
String lastUniqueId = cachePlusOps.get(lastKey); | |||
if (StrUtil.isBlank(lastUniqueId)) { | |||
lastUniqueId = BizUtils.uuid32(); | |||
CacheKey key = new CacheKey(); | |||
key.setKey(RK_REGISTER_UNIQUE_ID + lastUniqueId); | |||
key.setExpire(REGISTER_EXPIRED_DURATION); | |||
cachePlusOps.set(lastKey, lastUniqueId); | |||
String gmtUserTime = LoginUserUtil.getUserId() + "#" + System.currentTimeMillis(); | |||
cachePlusOps.set(key, gmtUserTime); | |||
} | |||
return WebProperties.webUrl + "/pm/expert/ephemeral/" + lastUniqueId + "/registration"; | |||
} | |||
public void redirectToRegistrationUrl(String uniqueId, HttpServletResponse response) throws IOException { | |||
CacheKey cacheKey = new CacheKey(RK_REGISTER_UNIQUE_ID + uniqueId); | |||
response.setContentType(MediaType.TEXT_PLAIN_VALUE); | |||
response.setCharacterEncoding(StandardCharsets.UTF_8.name()); | |||
try { | |||
if (cachePlusOps.exists(cacheKey)) { | |||
response.sendRedirect(WebProperties.webUrl + WebProperties.expertRegistrationUrl); | |||
} else { | |||
response.getWriter().write("专家报名链接已失效"); | |||
} | |||
} catch (Exception e) { | |||
log.error("专家报名链接重定向异常:", e); | |||
response.getWriter().write("专家报名链接访问异常"); | |||
} | |||
} | |||
/** | |||
@@ -95,7 +144,8 @@ public class ExpertManage { | |||
@Transactional(rollbackFor = Exception.class) | |||
public Long expertRecommendProofSubmit(List<DictionaryFieldInfo> recommendedWay, List<FileBasicInfo> recommendProofFile, Long expertUserId) { | |||
public Long expertRecommendProofSubmit | |||
(List<DictionaryFieldInfo> recommendedWay, List<FileBasicInfo> recommendProofFile, Long expertUserId) { | |||
// 用户id | |||
ExpertUserFullInfo expertUserFullInfo = iExpertUserFullInfoService.getByUserId(expertUserId); | |||
// 判断专家状态,是否可以进行证明材料提交 | |||
@@ -16,10 +16,17 @@ import org.springframework.stereotype.Component; | |||
@Component | |||
public class WebProperties { | |||
public static String expertRegistrationUrl; | |||
public static String webUrl; | |||
public static String provincialUrl; | |||
@Value("${expert-registration.url:/expertEnroll}") | |||
private void setExpertRegistrationUrl(String url) { | |||
expertRegistrationUrl = url; | |||
} | |||
@Value("${web.url:}") | |||
private void setWebUrl(String url) { | |||
webUrl = url; | |||
@@ -1,7 +1,9 @@ | |||
package com.ningdatech.pmapi.projectdeclared.utils; | |||
import com.baomidou.mybatisplus.core.toolkit.StringPool; | |||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||
import com.ningdatech.basic.function.VUtils; | |||
import com.ningdatech.basic.util.StrPool; | |||
import com.ningdatech.pmapi.common.constant.BizConst; | |||
import com.ningdatech.pmapi.common.constant.RegionConst; | |||
import com.ningdatech.pmapi.gov.contants.BizProjectContant; | |||
@@ -9,7 +11,9 @@ import com.ningdatech.pmapi.gov.model.dto.GovBizProjectApplyDTO; | |||
import com.ningdatech.pmapi.gov.model.dto.GovBizProjectBaseinfoDTO; | |||
import com.ningdatech.pmapi.gov.model.dto.GovBizProjectSaveDTO; | |||
import com.ningdatech.pmapi.gov.model.entity.GovBizProjectApply; | |||
import com.ningdatech.pmapi.gov.model.entity.GovBizProjectBaseinfo; | |||
import com.ningdatech.pmapi.gov.service.IGovBizProjectApplyService; | |||
import com.ningdatech.pmapi.gov.service.IGovBizProjectBaseinfoService; | |||
import com.ningdatech.pmapi.projectdeclared.contants.ProjectCodeContant; | |||
import com.ningdatech.pmapi.projectlib.model.dto.ProjectDTO; | |||
import com.ningdatech.pmapi.projectlib.model.entity.Project; | |||
@@ -34,7 +38,7 @@ public class GenerateProjectCodeUtil { | |||
private IProjectService projectService; | |||
@Autowired | |||
private IGovBizProjectApplyService applyService; | |||
private IGovBizProjectBaseinfoService baseinfoService; | |||
public String generateProjectCode(ProjectDTO project){ | |||
// 获取所属行政区划代码(9位) | |||
@@ -72,7 +76,7 @@ public class GenerateProjectCodeUtil { | |||
return areaCode + year + projectType + serialNumber; | |||
} | |||
public String generateProjectCode(GovBizProjectSaveDTO dto){ | |||
public String generateProjectCode(GovBizProjectSaveDTO dto) { | |||
// 获取所属行政区划代码(9位) | |||
GovBizProjectBaseinfoDTO baseinfo = dto.getBaseinfo(); | |||
GovBizProjectApplyDTO apply = dto.getApply(); | |||
@@ -80,19 +84,22 @@ public class GenerateProjectCodeUtil { | |||
VUtils.isTrue(Objects.isNull(baseinfo)).throwMessage("没有项目基本信息 无法生成项目编号!"); | |||
VUtils.isTrue(Objects.isNull(apply)).throwMessage("没有项目申报信息 无法生成项目编号!"); | |||
String areaCode = (StringUtils.isNotBlank(baseinfo.getBaseAreaCode())?baseinfo.getBaseAreaCode(): RegionConst.RC_LS + BizConst.NINE_AREA_CODE_LAST); | |||
String areaCode = (StringUtils.isNotBlank(baseinfo.getBaseAreaCode()) ? baseinfo.getBaseAreaCode() : RegionConst.RC_LS + BizConst.NINE_AREA_CODE_LAST); | |||
// 获取建设年度 (10-13) | |||
String year = Objects.nonNull(apply.getBaseProjSetYear()) ? apply.getBaseProjSetYear() | |||
: String.valueOf(LocalDateTime.now().getYear()); | |||
// 14-15 项目类型 | |||
String projectType = StringUtils.isNotBlank(baseinfo.getBaseProjType()) ? baseinfo.getBaseProjType() : | |||
BizProjectContant.ProjectCollection.IS_EFFECTIVE; | |||
String currentCode = areaCode + year + projectType; | |||
// 16-20 项目序号00001 | |||
Long max = applyService.count(Wrappers.lambdaQuery(GovBizProjectApply.class) | |||
.eq(GovBizProjectApply::getBaseProjSetYear,apply.getBaseProjSetYear())); | |||
Long maxCurrent = max + 1; | |||
String serialNumber = String.format(ProjectCodeContant.SHUZI_5,maxCurrent); | |||
GovBizProjectBaseinfo baseMax = baseinfoService.getOne(Wrappers.lambdaQuery(GovBizProjectBaseinfo.class) | |||
.like(GovBizProjectBaseinfo::getBaseProjId, currentCode) | |||
.orderByDesc(GovBizProjectBaseinfo::getBaseProjId) | |||
.last(BizConst.LIMIT_1)); | |||
Long max = Objects.isNull(baseMax) ? 0L : Long.valueOf(baseMax.getBaseProjId().substring(baseMax.getBaseProjId().length() - 5, baseMax.getBaseProjId().length())); | |||
max = max + 1; | |||
// 生成20位的项目编号 | |||
return areaCode + year + projectType + serialNumber; | |||
return currentCode + String.format(ProjectCodeContant.SHUZI_5, max); | |||
} | |||
} |
@@ -238,5 +238,7 @@ login: | |||
phone-verify-code: | |||
skip: true | |||
url: http://lspm.ningdatech.com/login | |||
web: | |||
url: http://lspm.ningdatech.com | |||
@@ -241,3 +241,5 @@ login: | |||
phone-verify-code: | |||
skip: true | |||
url: http://60.188.225.145:8080/login | |||
web: | |||
url: http://60.188.225.145:8080 |
@@ -241,3 +241,5 @@ login: | |||
phone-verify-code: | |||
skip: false | |||
url: http://60.188.225.145/login | |||
web: | |||
url: http://60.188.225.145 |
@@ -38,6 +38,7 @@ security: | |||
- /api/v1/irs/** | |||
- /api/v1/wps-convert/** | |||
- /api/v1/belong-org/business-strip/list | |||
- /expert/ephemeral/*/registration | |||
ignore-csrf-urls: | |||
- /api/v1/user/auth/** | |||
- /v2/api-docs | |||
@@ -68,6 +69,7 @@ security: | |||
- /api/v1/irs/** | |||
- /api/v1/wps-convert/** | |||
- /api/v1/belong-org/business-strip/list | |||
- /expert/ephemeral/*/registration | |||
role-map: | |||
"engineer": | |||
"project_manager": | |||
@@ -38,6 +38,7 @@ security: | |||
- /api/v1/irs/** | |||
- /api/v1/wps-convert/** | |||
- /api/v1/belong-org/business-strip/list | |||
- /expert/ephemeral/*/registration | |||
ignore-csrf-urls: | |||
- /api/v1/user/auth/** | |||
- /v2/api-docs | |||
@@ -68,6 +69,7 @@ security: | |||
- /api/v1/irs/** | |||
- /api/v1/wps-convert/** | |||
- /api/v1/belong-org/business-strip/list | |||
- /expert/ephemeral/*/registration | |||
role-map: | |||
"engineer": | |||
"project_manager": | |||
@@ -38,6 +38,7 @@ security: | |||
- /api/v1/irs/** | |||
- /api/v1/wps-convert/** | |||
- /api/v1/belong-org/business-strip/list | |||
- /expert/ephemeral/*/registration | |||
ignore-csrf-urls: | |||
- /api/v1/user/auth/** | |||
- /v2/api-docs | |||
@@ -68,6 +69,7 @@ security: | |||
- /api/v1/irs/** | |||
- /api/v1/wps-convert/** | |||
- /api/v1/belong-org/business-strip/list | |||
- /expert/ephemeral/*/registration | |||
role-map: | |||
"engineer": | |||
"project_manager": | |||
@@ -79,11 +79,16 @@ public class ProjectCollectionTest extends AppTests { | |||
for(String baseProjId : baseProjIds){ | |||
GovBizProjectBaseinfo baseinfo = baseinfoService.getOne(Wrappers.lambdaQuery(GovBizProjectBaseinfo.class) | |||
.eq(GovBizProjectBaseinfo::getBaseProjId, baseProjId) | |||
.orderByDesc(GovBizProjectBaseinfo::getTongTime) | |||
.last(BizConst.LIMIT_1)); | |||
GovBizProjectApply apply = applyService.getOne(Wrappers.lambdaQuery(GovBizProjectApply.class) | |||
.eq(GovBizProjectApply::getBaseProjId, baseProjId) | |||
.orderByDesc(GovBizProjectApply::getTongTime) | |||
.last(BizConst.LIMIT_1)); | |||
if(Objects.isNull(baseinfo)){ | |||
System.out.println("项目不存在 直接下一个"); | |||
continue; | |||
} | |||
GovBizProjectSaveDTO saveDTO = new GovBizProjectSaveDTO(); | |||
saveDTO.setApply(BeanUtil.copyProperties(apply, GovBizProjectApplyDTO.class)); | |||
saveDTO.setBaseinfo(BeanUtil.copyProperties(baseinfo, GovBizProjectBaseinfoDTO.class)); | |||
@@ -93,18 +98,45 @@ public class ProjectCollectionTest extends AppTests { | |||
baseinfoService.updateById(baseinfo); | |||
apply.setBaseProjId(newProjId); | |||
applyService.updateById(apply); | |||
approveService.update(Wrappers.lambdaUpdate(GovBizProjectApprove.class) | |||
.eq(GovBizProjectApprove::getBaseProjId,baseProjId) | |||
.set(GovBizProjectApprove::getBaseProjId,newProjId)); | |||
cimplementService.update(Wrappers.lambdaUpdate(GovBizProjectCimplement.class) | |||
.eq(GovBizProjectCimplement::getBaseProjId,baseProjId) | |||
.set(GovBizProjectCimplement::getBaseProjId,newProjId)); | |||
mimplementService.update(Wrappers.lambdaUpdate(GovBizProjectMimplement.class) | |||
.eq(GovBizProjectMimplement::getBaseProjId,baseProjId) | |||
.set(GovBizProjectMimplement::getBaseProjId,newProjId)); | |||
procureService.update(Wrappers.lambdaUpdate(GovBizProjectProcure.class) | |||
.eq(GovBizProjectProcure::getBaseProjId,baseProjId) | |||
.set(GovBizProjectProcure::getBaseProjId,newProjId)); | |||
GovBizProjectApprove approve = approveService.getOne(Wrappers.lambdaUpdate(GovBizProjectApprove.class) | |||
.eq(GovBizProjectApprove::getBaseProjId, baseProjId) | |||
.orderByDesc(GovBizProjectApprove::getTongTime) | |||
.last(BizConst.LIMIT_1)); | |||
if(Objects.nonNull(approve)){ | |||
approve.setBaseProjId(newProjId); | |||
approveService.updateById(approve); | |||
} | |||
GovBizProjectCimplement cimplement = cimplementService.getOne(Wrappers.lambdaQuery(GovBizProjectCimplement.class) | |||
.eq(GovBizProjectCimplement::getBaseProjId, baseProjId) | |||
.orderByDesc(GovBizProjectCimplement::getTongTime) | |||
.last(BizConst.LIMIT_1)); | |||
if(Objects.nonNull(cimplement)){ | |||
cimplement.setBaseProjId(newProjId); | |||
cimplement.setBaseBidCode(newProjId); | |||
cimplementService.updateById(cimplement); | |||
} | |||
GovBizProjectMimplement mimplement = mimplementService.getOne(Wrappers.lambdaQuery(GovBizProjectMimplement.class) | |||
.eq(GovBizProjectMimplement::getBaseProjId, baseProjId) | |||
.orderByDesc(GovBizProjectMimplement::getTongTime) | |||
.last(BizConst.LIMIT_1)); | |||
if(Objects.nonNull(mimplement)){ | |||
mimplement.setBaseProjId(newProjId); | |||
mimplement.setBaseBidCode(newProjId); | |||
mimplementService.updateById(mimplement); | |||
} | |||
List<GovBizProjectProcure> procures = procureService.list(Wrappers.lambdaUpdate(GovBizProjectProcure.class) | |||
.eq(GovBizProjectProcure::getBaseProjId, baseProjId)); | |||
for(GovBizProjectProcure procure : procures){ | |||
procure.setBaseProjId(newProjId); | |||
procure.setBaseBidCode(newProjId + "-" + procure.getBaseBidCode().split("-")[1]); | |||
procureService.updateById(procure); | |||
} | |||
} | |||
} | |||