CMM 1 year ago
parent
commit
e5405956cb
32 changed files with 608 additions and 244 deletions
  1. +0
    -22
      pmapi/pom.xml
  2. +2
    -2
      pmapi/src/main/java/com/ningdatech/pmapi/common/helper/UserInfoHelper.java
  3. +11
    -2
      pmapi/src/main/java/com/ningdatech/pmapi/common/helper/impl/UserInfoHelperImpl.java
  4. +1
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/fiscal/entity/CompanyFiscalCode.java
  5. +3
    -3
      pmapi/src/main/java/com/ningdatech/pmapi/fiscal/manage/CompanyFiscalCodeManage.java
  6. +1
    -2
      pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/controller/PrequalificationDeclaredController.java
  7. +0
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/ConstructionPlanManage.java
  8. +18
    -4
      pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DeclaredProjectManage.java
  9. +14
    -6
      pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/PrequalificationDeclaredProjectManage.java
  10. +87
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/ReviewByDeptJointManage.java
  11. +50
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/ReviewByProvincialDeptManage.java
  12. +3
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/entity/ProjectInst.java
  13. +0
    -64
      pmapi/src/main/java/com/ningdatech/pmapi/rabbitmq/config/DirectRabbitConfig.java
  14. +0
    -47
      pmapi/src/main/java/com/ningdatech/pmapi/rabbitmq/config/RabbitConfig.java
  15. +0
    -59
      pmapi/src/main/java/com/ningdatech/pmapi/rabbitmq/controller/TestController.java
  16. +93
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/scheduler/task/ProjectStatusFlowTask.java
  17. +1
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/signature/entity/CompanySignature.java
  18. +12
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/staging/contants/StagingContant.java
  19. +13
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/staging/mapper/ProjectStagingMapper.java
  20. +12
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/staging/mapper/ProjectStagingMapper.xml
  21. +69
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/staging/model/entity/ProjectStaging.java
  22. +18
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/staging/serivice/IProjectStagingService.java
  23. +77
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/staging/serivice/impl/ProjectStagingServiceImpl.java
  24. +66
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/staging/utils/ProjectStatusFlowMapUtil.java
  25. +6
    -6
      pmapi/src/main/java/com/ningdatech/pmapi/sys/controller/NoticeController.java
  26. +19
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/user/manage/UserAuthLoginManage.java
  27. +23
    -3
      pmapi/src/main/java/com/ningdatech/pmapi/user/manage/UserInfoManage.java
  28. +3
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/user/model/po/ReqUserInfoListPO.java
  29. +5
    -4
      pmapi/src/main/java/com/ningdatech/pmapi/user/util/LoginUserUtil.java
  30. +1
    -0
      pmapi/src/main/resources/security/auth-dev.yml
  31. +0
    -11
      pmapi/src/test/resources/application-dev.yml
  32. +0
    -5
      pom.xml

+ 0
- 22
pmapi/pom.xml View File

@@ -61,18 +61,6 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId> <artifactId>spring-boot-starter-validation</artifactId>
</dependency> </dependency>
<!-- <dependency>-->
<!-- <groupId>org.springframework.data</groupId>-->
<!-- <artifactId>spring-data-jpa</artifactId>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.hibernate</groupId>-->
<!-- <artifactId>hibernate-core</artifactId>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-starter-data-jpa</artifactId>-->
<!-- </dependency>-->
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-boot-starter-web</artifactId>
@@ -88,12 +76,6 @@
<optional>true</optional> <optional>true</optional>
<scope>true</scope> <scope>true</scope>
</dependency> </dependency>
<!-- pg -->
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.4.2</version>
</dependency>
<dependency> <dependency>
<groupId>com.alibaba</groupId> <groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId> <artifactId>druid-spring-boot-starter</artifactId>
@@ -264,10 +246,6 @@
<systemPath>${basedir}/src/lib/zwdd-sdk-java-1.2.0.jar</systemPath> <systemPath>${basedir}/src/lib/zwdd-sdk-java-1.2.0.jar</systemPath>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.ningdatech</groupId>
<artifactId>nd-rabbitmq-starter</artifactId>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId> <groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId> <artifactId>httpclient</artifactId>
</dependency> </dependency>


+ 2
- 2
pmapi/src/main/java/com/ningdatech/pmapi/common/helper/UserInfoHelper.java View File

@@ -12,11 +12,11 @@ import org.springframework.stereotype.Component;
public interface UserInfoHelper { public interface UserInfoHelper {


/** /**
* 根据用户id 获取 用户所属公司id
* 根据用户id 获取 用户所属公司 organizationCode
* *
* @param userId * @param userId
* @return * @return
*/ */
Long getCompanyId(Long userId);
String getOrganizationCode(Long userId);


} }

+ 11
- 2
pmapi/src/main/java/com/ningdatech/pmapi/common/helper/impl/UserInfoHelperImpl.java View File

@@ -1,6 +1,9 @@
package com.ningdatech.pmapi.common.helper.impl; package com.ningdatech.pmapi.common.helper.impl;


import com.ningdatech.pmapi.common.helper.UserInfoHelper; import com.ningdatech.pmapi.common.helper.UserInfoHelper;
import com.ningdatech.pmapi.user.manage.UserAuthLoginManage;
import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;


/** /**
@@ -8,11 +11,17 @@ import org.springframework.stereotype.Component;
* @date 2023/2/10 下午4:40 * @date 2023/2/10 下午4:40
*/ */
@Component @Component
@RequiredArgsConstructor
public class UserInfoHelperImpl implements UserInfoHelper { public class UserInfoHelperImpl implements UserInfoHelper {




private final UserAuthLoginManage userAuthLoginManage;


@Override @Override
public Long getCompanyId(Long userId) {
return null;
public String getOrganizationCode(Long userId) {
UserFullInfoDTO userFullInfo = userAuthLoginManage.getUserFullInfo(userId);

return userFullInfo.getOrganizationCode();
} }
} }

+ 1
- 1
pmapi/src/main/java/com/ningdatech/pmapi/fiscal/entity/CompanyFiscalCode.java View File

@@ -26,7 +26,7 @@ public class CompanyFiscalCode implements Serializable {


private String fiscalCode; private String fiscalCode;


private Long companyId;
private String organizationCode;


private LocalDateTime createOn; private LocalDateTime createOn;




+ 3
- 3
pmapi/src/main/java/com/ningdatech/pmapi/fiscal/manage/CompanyFiscalCodeManage.java View File

@@ -28,14 +28,14 @@ public class CompanyFiscalCodeManage {


public void fiscalCodeConfigure(ReqCompanyFiscalCodeAndSealSnPO reqCompanyFiscalCodeAndSealSnPO) { public void fiscalCodeConfigure(ReqCompanyFiscalCodeAndSealSnPO reqCompanyFiscalCodeAndSealSnPO) {
Long userId = LoginUserUtil.getUserId(); Long userId = LoginUserUtil.getUserId();
Long companyId = userInfoHelper.getCompanyId(userId);
String organizationCode = userInfoHelper.getOrganizationCode(userId);
// TODO 校验用户权限 // TODO 校验用户权限


// 保存财政编码配置 // 保存财政编码配置
String fiscalCode = reqCompanyFiscalCodeAndSealSnPO.getFiscalCode(); String fiscalCode = reqCompanyFiscalCodeAndSealSnPO.getFiscalCode();
CompanyFiscalCode companyFiscalCodeSaveRecord = new CompanyFiscalCode(); CompanyFiscalCode companyFiscalCodeSaveRecord = new CompanyFiscalCode();
companyFiscalCodeSaveRecord.setFiscalCode(fiscalCode); companyFiscalCodeSaveRecord.setFiscalCode(fiscalCode);
companyFiscalCodeSaveRecord.setCompanyId(companyId);
companyFiscalCodeSaveRecord.setOrganizationCode(organizationCode);
companyFiscalCodeSaveRecord.setCreateOn(LocalDateTime.now()); companyFiscalCodeSaveRecord.setCreateOn(LocalDateTime.now());
companyFiscalCodeSaveRecord.setUpdateOn(LocalDateTime.now()); companyFiscalCodeSaveRecord.setUpdateOn(LocalDateTime.now());
companyFiscalCodeSaveRecord.setCreateBy(userId); companyFiscalCodeSaveRecord.setCreateBy(userId);
@@ -46,7 +46,7 @@ public class CompanyFiscalCodeManage {
String sealSn = reqCompanyFiscalCodeAndSealSnPO.getSealSn(); String sealSn = reqCompanyFiscalCodeAndSealSnPO.getSealSn();
CompanySignature companySignatureSaveRecord = new CompanySignature(); CompanySignature companySignatureSaveRecord = new CompanySignature();
companySignatureSaveRecord.setSealSn(sealSn); companySignatureSaveRecord.setSealSn(sealSn);
companySignatureSaveRecord.setCompanyId(companyId);
companySignatureSaveRecord.setOrganizationCode(organizationCode);
companySignatureSaveRecord.setCreateOn(LocalDateTime.now()); companySignatureSaveRecord.setCreateOn(LocalDateTime.now());
companySignatureSaveRecord.setUpdateOn(LocalDateTime.now()); companySignatureSaveRecord.setUpdateOn(LocalDateTime.now());
companySignatureSaveRecord.setCreateBy(userId); companySignatureSaveRecord.setCreateBy(userId);


+ 1
- 2
pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/controller/PrequalificationDeclaredController.java View File

@@ -49,7 +49,6 @@ public class PrequalificationDeclaredController {
@ApiOperation(value = "申报预审", notes = "申报预审") @ApiOperation(value = "申报预审", notes = "申报预审")
@PostMapping("/start") @PostMapping("/start")
public String startTheProcess(@Validated @RequestBody DefaultDeclaredDTO dto) { public String startTheProcess(@Validated @RequestBody DefaultDeclaredDTO dto) {
String instanceId = prequalificationDeclaredProjectManage.startTheProcess(dto);
return "提交预审 【" + instanceId + "】 成功";
return prequalificationDeclaredProjectManage.startTheProcess(dto);
} }
} }

+ 0
- 1
pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/ConstructionPlanManage.java View File

@@ -82,7 +82,6 @@ public class ConstructionPlanManage {
VUtils.isTrue(!ProjectStatusEnum.PLAN_TO_BE_DECLARED.getCode().equals(projectInfo.getStatus()) || VUtils.isTrue(!ProjectStatusEnum.PLAN_TO_BE_DECLARED.getCode().equals(projectInfo.getStatus()) ||
!ProjectStatusEnum.NOT_APPROVED.getCode().equals(projectInfo.getStage())) !ProjectStatusEnum.NOT_APPROVED.getCode().equals(projectInfo.getStage()))
.throwMessage("提交失败 该项目不是 方案待申报状态或者未立项阶段"); .throwMessage("提交失败 该项目不是 方案待申报状态或者未立项阶段");
// TODO 再判断 该项目是否 真实走完 预审审批


ProcessStartParamsVo params = new ProcessStartParamsVo(); ProcessStartParamsVo params = new ProcessStartParamsVo();
params.setUser(dto.getUser()); params.setUser(dto.getUser());


+ 18
- 4
pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DeclaredProjectManage.java View File

@@ -114,6 +114,14 @@ public class DeclaredProjectManage {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public String startTheProcess(DefaultDeclaredDTO dto) { public String startTheProcess(DefaultDeclaredDTO dto) {
ProjectDTO projectInfo = dto.getProjectInfo(); ProjectDTO projectInfo = dto.getProjectInfo();

//如果是重新提交的话 判断下 项目是否存在
if(Objects.nonNull(projectInfo.getId())){
Project oldProject = projectService.getById(projectInfo.getId());
VUtils.isTrue(Objects.isNull(oldProject))
.throwMessage(String.format("重新提交失败 该项目【%s】不存在",projectInfo.getId()));
}

String regionCode = projectInfo.getAreaCode(); String regionCode = projectInfo.getAreaCode();


WflowModels model = processModelService.getOne(Wrappers.lambdaQuery(WflowModels.class) WflowModels model = processModelService.getOne(Wrappers.lambdaQuery(WflowModels.class)
@@ -144,8 +152,8 @@ public class DeclaredProjectManage {
String instanceId = processService.startProcess(model.getProcessDefId(), params); String instanceId = processService.startProcess(model.getProcessDefId(), params);
log.info("申报项目成功 【{}】", instanceId); log.info("申报项目成功 【{}】", instanceId);


//保存项目
saveProject(dto.getProjectInfo(), instanceId, regionCode);
//如果是重新提交的话 判断下 项目是否存在
saveOrUpdateProject(dto.getProjectInfo(), instanceId, regionCode);


return instanceId; return instanceId;
} }
@@ -174,6 +182,11 @@ public class DeclaredProjectManage {
throw new BusinessException(String.format("此 【%s】区域找不到单位流程配置", regionCode)); throw new BusinessException(String.format("此 【%s】区域找不到单位流程配置", regionCode));
} }


//首先要判断 项目当前状态 是不是 单位内部拒绝
VUtils.isTrue(!ProjectStatusEnum.UNDER_INTERNAL_AUDIT_NOT_PASS.getCode().equals(projectInfo.getStatus()) ||
!ProjectStatusEnum.NOT_APPROVED.getCode().equals(projectInfo.getStage()))
.throwMessage("提交失败 该项目不是 单位内部拒绝审核状态或者未立项阶段");

ProcessStartParamsVo params = new ProcessStartParamsVo(); ProcessStartParamsVo params = new ProcessStartParamsVo();
params.setUser(dto.getUser()); params.setUser(dto.getUser());
params.setProcessUsers(Collections.emptyMap()); params.setProcessUsers(Collections.emptyMap());
@@ -221,7 +234,7 @@ public class DeclaredProjectManage {
* @param projectDto * @param projectDto
* @param instanceId * @param instanceId
*/ */
private void saveProject(ProjectDTO projectDto, String instanceId, String regionCode) {
private void saveOrUpdateProject(ProjectDTO projectDto, String instanceId, String regionCode) {
//流程启动之后 入库项目 重要业务信息 用于列表查询 展示 //流程启动之后 入库项目 重要业务信息 用于列表查询 展示
try { try {
//保存项目表信息 //保存项目表信息
@@ -233,7 +246,7 @@ public class DeclaredProjectManage {
project.setStage(ProjectStatusEnum.NOT_APPROVED.getCode()); project.setStage(ProjectStatusEnum.NOT_APPROVED.getCode());
project.setStatus(ProjectStatusEnum.UNDER_INTERNAL_AUDIT.getCode()); project.setStatus(ProjectStatusEnum.UNDER_INTERNAL_AUDIT.getCode());
project.setInstCode(instanceId); project.setInstCode(instanceId);
projectService.save(project);
projectService.saveOrUpdate(project);
//保存项目应用 //保存项目应用
if (CollUtil.isNotEmpty(projectDto.getApplicationList())) { if (CollUtil.isNotEmpty(projectDto.getApplicationList())) {
List<ProjectApplication> applications = projectDto.getApplicationList().stream().map(application -> { List<ProjectApplication> applications = projectDto.getApplicationList().stream().map(application -> {
@@ -250,6 +263,7 @@ public class DeclaredProjectManage {
projectInst.setInstCode(instanceId); projectInst.setInstCode(instanceId);
projectInst.setCreatOn(LocalDateTime.now()); projectInst.setCreatOn(LocalDateTime.now());
projectInst.setUpdateOn(LocalDateTime.now()); projectInst.setUpdateOn(LocalDateTime.now());
projectInst.setInstType(ProjectProcessStageEnum.ORG_INTERNAL_APPROVAL_PROCESS.getCode());
projectInstService.save(projectInst); projectInstService.save(projectInst);
} catch (Exception e) { } catch (Exception e) {
log.error("项目信息入库错误 ", e); log.error("项目信息入库错误 ", e);


+ 14
- 6
pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/PrequalificationDeclaredProjectManage.java View File

@@ -15,6 +15,7 @@ import com.ningdatech.pmapi.projectlib.model.entity.Project;
import com.ningdatech.pmapi.projectlib.model.entity.ProjectInst; import com.ningdatech.pmapi.projectlib.model.entity.ProjectInst;
import com.ningdatech.pmapi.projectlib.service.IProjectInstService; import com.ningdatech.pmapi.projectlib.service.IProjectInstService;
import com.ningdatech.pmapi.projectlib.service.IProjectService; import com.ningdatech.pmapi.projectlib.service.IProjectService;
import com.ningdatech.pmapi.staging.serivice.IProjectStagingService;
import com.wflow.bean.entity.WflowModels; import com.wflow.bean.entity.WflowModels;
import com.wflow.exception.BusinessException; import com.wflow.exception.BusinessException;
import com.wflow.workflow.bean.vo.ProcessStartParamsVo; import com.wflow.workflow.bean.vo.ProcessStartParamsVo;
@@ -52,6 +53,8 @@ public class PrequalificationDeclaredProjectManage {


private final IProjectInstService projectInstService; private final IProjectInstService projectInstService;


private final IProjectStagingService projectStagingService;

/** /**
* 提交预审 * 提交预审
* *
@@ -95,8 +98,13 @@ public class PrequalificationDeclaredProjectManage {
//如果是省级部门 需要联审的(申报金额大于1000万 并且是市级项目) //如果是省级部门 需要联审的(申报金额大于1000万 并且是市级项目)
if(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS if(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS
.getCode().equals(projectInfo.getStatus())){ .getCode().equals(projectInfo.getStatus())){
//TODO 对接外部 省级
instanceId = DeclaredProjectContant.Instance.PROVINCE_INSTANCE_ID;
//入库暂存表 后续处理 对接外部接口
projectInfo.setUpdateOn(LocalDateTime.now());
if(projectStagingService.addByProject(projectInfo,"省级部门联审")
&& projectService.updateById(projectInfo)){
return "提交省级部门联审成功";
}
return "提交省级部门联审失败";
}else if(ProjectStatusEnum.PRE_APPLYING }else if(ProjectStatusEnum.PRE_APPLYING
.getCode().equals(projectInfo.getStatus())){ .getCode().equals(projectInfo.getStatus())){
//如果是非省级联审的项目 直接提交 预审 //如果是非省级联审的项目 直接提交 预审
@@ -115,14 +123,13 @@ public class PrequalificationDeclaredProjectManage {
log.info("提交预审项目成功 【{}】", instanceId); log.info("提交预审项目成功 【{}】", instanceId);


//保存预审项目 //保存预审项目
if(Objects.nonNull(instanceId)){
modifyProject(projectInfo, instanceId);
}
modifyProject(projectInfo, instanceId);

}else{ }else{
throw new BusinessException("项目状态 错误 project :" + JSON.toJSONString(projectInfo)); throw new BusinessException("项目状态 错误 project :" + JSON.toJSONString(projectInfo));
} }


return instanceId;
return "提交预审成功【" + instanceId + "】";
} }


/** /**
@@ -146,6 +153,7 @@ public class PrequalificationDeclaredProjectManage {
projectInst.setInstCode(instanceId); projectInst.setInstCode(instanceId);
projectInst.setCreatOn(LocalDateTime.now()); projectInst.setCreatOn(LocalDateTime.now());
projectInst.setUpdateOn(LocalDateTime.now()); projectInst.setUpdateOn(LocalDateTime.now());
projectInst.setInstType(ProjectProcessStageEnum.PROJECT_PREQUALIFICATION_APPROVAL_PROCESS.getCode());
projectInstService.save(projectInst); projectInstService.save(projectInst);
} catch (Exception e) { } catch (Exception e) {
log.error("提交预审 项目信息修改 错误 ", e); log.error("提交预审 项目信息修改 错误 ", e);


+ 87
- 0
pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/ReviewByDeptJointManage.java View File

@@ -0,0 +1,87 @@
package com.ningdatech.pmapi.projectdeclared.manage;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ningdatech.basic.function.VUtils;
import com.ningdatech.pmapi.common.enumeration.ProjectProcessStageEnum;
import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum;
import com.ningdatech.pmapi.projectlib.model.entity.Project;
import com.ningdatech.pmapi.projectlib.service.IProjectInstService;
import com.ningdatech.pmapi.projectlib.service.IProjectService;
import com.wflow.bean.entity.WflowModels;
import com.wflow.exception.BusinessException;
import com.wflow.workflow.service.ProcessInstanceService;
import com.wflow.workflow.service.ProcessModelService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.util.Objects;

/**
* @Classname ReviewByDeptJointManage
* @Description 部门联审
* @Date 2023/2/17 14:48
* @Author PoffyZhang
*/
@Component
@Slf4j
@RequiredArgsConstructor
public class ReviewByDeptJointManage {

private final IProjectService projectService;

private final ProcessModelService processModelService;

private final ProcessInstanceService processService;

private final IProjectInstService projectInstService;

/**
* 省级部门联审
* @param project
* @return
*/
@Transactional(rollbackFor = Exception.class)
public Boolean startTheProcess(Project project) {
VUtils.isTrue(Objects.isNull(project.getId())).throwMessage("提交失败 缺少项目ID!");
Project projectInfo = projectService.getById(project.getId());
VUtils.isTrue(Objects.isNull(projectInfo)).throwMessage("提交失败 此项目不存在!");
String regionCode = projectInfo.getAreaCode();

WflowModels model = processModelService.getOne(Wrappers.lambdaQuery(WflowModels.class)
.eq(WflowModels::getRegionCode, regionCode)
.eq(WflowModels::getProcessType, ProjectProcessStageEnum.DEPARTMENT_JOINT_APPROVAL_PROCESS.getCode())
.last("limit 1"));

if (Objects.isNull(model)) {
log.error("此 【{}】区域找不到 部门联审申报流程配置", regionCode);
throw new BusinessException(String.format("此 【%s】区域找不到 部门联审申报流程配置", regionCode));
}
//要判断 项目当前状态 是不是 部门联审
VUtils.isTrue(!ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW.getCode().equals(projectInfo.getStatus()) ||
!ProjectStatusEnum.NOT_APPROVED.getCode().equals(projectInfo.getStage()))
.throwMessage("提交失败 该项目不是 省级部门联审状态状态或者未立项阶段");

// 再判断 该项目是否 真实走完 预审审批 并且提取出 提交人
// projectInstService.
//
// ProcessStartParamsVo params = new ProcessStartParamsVo();
// params.setUser(dto.getUser());
// params.setProcessUsers(Collections.emptyMap());
// //放入条件判断的项目字段
// ProjectConditionDTO conditionDto = new ProjectConditionDTO();
// BeanUtils.copyProperties(projectInfo, conditionDto);
// dto.getFormData().putAll(
// JSON.parseObject(JSON.toJSONString(conditionDto), new TypeReference<Map<String, Object>>() {
// })
// );
// params.setFormData(dto.getFormData());
// String instanceId = processService.startProcess(model.getProcessDefId(), params);
// log.info("建设方案项目申报成功 【{}】", instanceId);
//
// //保存建设项目
// modifyProject(projectInfo, instanceId, projectInfo.getConstructionPlanFile());

return null;
}
}

+ 50
- 0
pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/ReviewByProvincialDeptManage.java View File

@@ -0,0 +1,50 @@
package com.ningdatech.pmapi.projectdeclared.manage;

import com.ningdatech.basic.function.VUtils;
import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum;
import com.ningdatech.pmapi.projectlib.model.entity.Project;
import com.ningdatech.pmapi.projectlib.service.IProjectService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.util.Objects;

/**
* @Classname ReviewByProvincialDeptManage
* @Description 省级部门联审
* @Date 2023/2/17 14:48
* @Author PoffyZhang
*/
@Component
@Slf4j
@RequiredArgsConstructor
public class ReviewByProvincialDeptManage {

private final IProjectService projectService;

/**
* 省级部门联审
* @param project
* @return
*/
@Transactional(rollbackFor = Exception.class)
public Boolean startTheProcess(Project project) {
VUtils.isTrue(Objects.isNull(project.getId())).throwMessage("提交失败 缺少项目ID!");
Project projectInfo = projectService.getById(project.getId());
VUtils.isTrue(Objects.isNull(projectInfo)).throwMessage("提交失败 此项目不存在!");
String regionCode = projectInfo.getAreaCode();

//首先要判断 项目当前状态 是不是 省级部门联审
VUtils.isTrue(!ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS.getCode().equals(projectInfo.getStatus()) ||
!ProjectStatusEnum.NOT_APPROVED.getCode().equals(projectInfo.getStage()))
.throwMessage("提交失败 该项目不是 省级部门联审状态状态或者未立项阶段");
// TODO 对接省级联审的接口
Boolean sucessProvince = Boolean.FALSE;
if(sucessProvince){
//成功了后
}

return Boolean.FALSE;
}
}

+ 3
- 0
pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/entity/ProjectInst.java View File

@@ -34,6 +34,9 @@ public class ProjectInst implements Serializable {
@ApiModelProperty("实例ID") @ApiModelProperty("实例ID")
private String instCode; private String instCode;


@ApiModelProperty("实例类型 1单位内部审批流程 2项目预审审批流程 3部门联合审批流程 4建设方案审批流程 5验收申报审批流程")
private Integer instType;

@ApiModelProperty("创建时间") @ApiModelProperty("创建时间")
private LocalDateTime creatOn; private LocalDateTime creatOn;




+ 0
- 64
pmapi/src/main/java/com/ningdatech/pmapi/rabbitmq/config/DirectRabbitConfig.java View File

@@ -1,64 +0,0 @@
package com.ningdatech.pmapi.rabbitmq.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
* @author zpf
* @version 1.0.0
* @Description 创建direct类型的交换机
* @createTime 2023年02月17日
*/
@Slf4j
@Configuration
public class DirectRabbitConfig {


private static final String QUEUE = "TestDirectQueue";
private static final String EXCHANGE = "TestDirectExchange";
private static final String ROUTING_KEY = "TestDirectRouting";

/**
* 创建一个名为TestDirectQueue的队列
*
* @return
*/
@Bean
public Queue testDirectQueue() {
// durable:是否持久化,默认是false,持久化队列:会被存储在磁盘上,当消息代理重启时仍然存在,暂存队列:当前连接有效
// exclusive:默认也是false,只能被当前创建的连接使用,而且当连接关闭后队列即被删除。此参考优先级高于durable
// autoDelete:是否自动删除,有消息者订阅本队列,然后所有消费者都解除订阅此队列,会自动删除。
// arguments:队列携带的参数,比如设置队列的死信队列,消息的过期时间等等。
return new Queue(QUEUE, true);
}

/**
* 创建一个名为TestDirectExchange的Direct类型的交换机
*
* @return
*/
@Bean
public DirectExchange testDirectExchange() {
// durable:是否持久化,默认是false,持久化交换机。
// autoDelete:是否自动删除,交换机先有队列或者其他交换机绑定的时候,然后当该交换机没有队列或其他交换机绑定的时候,会自动删除。
// arguments:交换机设置的参数,比如设置交换机的备用交换机(Alternate Exchange),当消息不能被路由到该交换机绑定的队列上时,会自动路由到备用交换机
return new DirectExchange(EXCHANGE, true, false);
}

/**
* 绑定交换机和队列
*
* @return
*/
@Bean
public Binding bindingDirect() {
//bind队列to交换机中with路由key(routing key)
return BindingBuilder.bind(testDirectQueue()).to(testDirectExchange()).with(ROUTING_KEY);
}
}


+ 0
- 47
pmapi/src/main/java/com/ningdatech/pmapi/rabbitmq/config/RabbitConfig.java View File

@@ -1,47 +0,0 @@
package com.ningdatech.pmapi.rabbitmq.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.ReturnedMessage;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Slf4j
@Configuration
public class RabbitConfig {

@Bean
public RabbitTemplate createRabbitTemplate(ConnectionFactory connectionFactory) {
RabbitTemplate rabbitTemplate = new RabbitTemplate();
rabbitTemplate.setConnectionFactory(connectionFactory);

//设置消息投递失败的策略,有两种策略:自动删除或返回到客户端。
//我们既然要做可靠性,当然是设置为返回到客户端(true是返回客户端,false是自动删除)
rabbitTemplate.setMandatory(true);

rabbitTemplate.setConfirmCallback(new RabbitTemplate.ConfirmCallback() {
@Override
public void confirm(CorrelationData correlationData, boolean ack, String cause) {
if (ack) {
log.info("ConfirmCallback 关联数据:{},投递成功,确认情况:{}", correlationData, ack);
} else {
log.info("ConfirmCallback 关联数据:{},投递失败,确认情况:{},原因:{}", correlationData, ack, cause);
}
}
});

rabbitTemplate.setReturnsCallback(new RabbitTemplate.ReturnsCallback() {
@Override
public void returnedMessage(ReturnedMessage returnedMessage) {
log.info("ReturnsCallback 消息:{},回应码:{},回应信息:{},交换机:{},路由键:{}"
, returnedMessage.getMessage(), returnedMessage.getReplyCode()
, returnedMessage.getReplyText(), returnedMessage.getExchange()
, returnedMessage.getRoutingKey());
}
});

return rabbitTemplate;
}
}

+ 0
- 59
pmapi/src/main/java/com/ningdatech/pmapi/rabbitmq/controller/TestController.java View File

@@ -1,59 +0,0 @@
package com.ningdatech.pmapi.rabbitmq.controller;

import com.alibaba.fastjson.JSON;
import com.ningdatech.pmapi.user.entity.UserInfo;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.UUID;

/**
* @author zpf
* @version 1.0.0
* @Description
* @createTime 2023年02月17日
*/
@RestController
public class TestController {

@Autowired
RabbitTemplate rabbitTemplate;


@GetMapping("/test")
public String test() {
return "producer ok";
}

@GetMapping("/push")
public String push() {
for (int i = 1; i <= 5; i++) {
//这个参数是用来做消息的唯一标识
//发布消息时使用,存储在消息的headers中
UserInfo user = new UserInfo();
user.setId(1L);
user.setRealName("汪涵");
// 关联的数据,可以用在消息投递失败的时候,作为一个线索,比如我把当前用户的id放进去,如果user消息投递失败
// 我后面可以根据id再找到user,再次投递数据
CorrelationData correlationData = new CorrelationData(UUID.randomUUID().toString().concat("-") + i);
if (i == 2) {
//故意把交换机写错,演示 confirmCallback
rabbitTemplate.convertAndSend("TestDirectExchange_111", "TestDirectRouting",
JSON.toJSONString(user), correlationData);
} else if (i == 3) {
//故意把路由键写错,演示 returnCallback
rabbitTemplate.convertAndSend("TestDirectExchange", "TestDirectRouting_111",
JSON.toJSONString(user), correlationData);
} else {
//正常发送
rabbitTemplate.convertAndSend("TestDirectExchange", "TestDirectRouting",
JSON.toJSONString(user), correlationData);
}
}
return "producer push ok";
}
}


+ 93
- 0
pmapi/src/main/java/com/ningdatech/pmapi/scheduler/task/ProjectStatusFlowTask.java View File

@@ -0,0 +1,93 @@
package com.ningdatech.pmapi.scheduler.task;

import cn.hutool.core.collection.CollUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ningdatech.pmapi.projectlib.model.entity.Project;
import com.ningdatech.pmapi.projectlib.service.IProjectService;
import com.ningdatech.pmapi.scheduler.contants.TaskContant;
import com.ningdatech.pmapi.staging.contants.StagingContant;
import com.ningdatech.pmapi.staging.model.entity.ProjectStaging;
import com.ningdatech.pmapi.staging.serivice.IProjectStagingService;
import com.ningdatech.pmapi.staging.utils.ProjectStatusFlowMapUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.function.Function;

/**
* @Classname ProjectStatusFlowTask
* @Description
* @Date 2023/2/20 10:12
* @Author PoffyZhang
*/
@Slf4j
@Component
@RequiredArgsConstructor
public class ProjectStatusFlowTask {

private final IProjectStagingService projectStagingService;

private final IProjectService projectService;

private final ProjectStatusFlowMapUtil projectStatusFlowMapUtil;

@Scheduled(cron = "0 */1 * * * ?")
public void statusFlow() throws UnknownHostException {
//测试暂时用自己电脑HOST
if (TaskContant.Host.HOST_ZPF.equals(InetAddress.getLocalHost().getHostName())) {
//1. 定时取 项目暂存表的数据 去进行状态继续流转
List<ProjectStaging> stagingList = projectStagingService.list(Wrappers.lambdaQuery(ProjectStaging.class)
.eq(ProjectStaging::getDead,Boolean.FALSE)
.ge(ProjectStaging::getNextTime, LocalDateTime.now())
.le(ProjectStaging::getRetryTimes, StagingContant.Retry.MAX_RETRY_TIMES)
.orderByAsc(ProjectStaging::getProjectId));

log.info("需要状态流转的项目 size:{} :{}",stagingList.size(), JSON.toJSONString(stagingList));
if(CollUtil.isEmpty(stagingList)){
log.info("没有需要状态流转的项目!");
return;
}

//遍历
for(ProjectStaging projectStaging : stagingList){
try{
Project project = projectService.getById(projectStaging.getProjectId());
if(Objects.isNull(project)){
log.info("此项目 【{}】 不存在",projectStaging.getProjectId());
continue;
}

//2. 用函数map 定位到 状态流转的函数
Map<Integer, Function<Project, Boolean>> reStartProcessMap =
projectStatusFlowMapUtil.statusFlowFunctionMap;

if(!reStartProcessMap.containsKey(project.getStatus())){
log.info("此项目 【{}】 当前状态 【{}】,没有对应流转函数",projectStaging.getProjectId(),project.getStatus());
continue;
}

Function<Project, Boolean> functionMap = reStartProcessMap.get(project.getStatus());
//执行对应的函数
if(functionMap.apply(project)){
//执行成功了 删除暂存的数据
projectStagingService.removeById(projectStaging);
}
}catch (Exception e){
log.error("项目流转 异常 projectId:【" + projectStaging.getProjectId() + "】 异常内容:" + e);
}finally {
//增加重试的次数 和下次扫描时间
projectStagingService.addRetryTimes(projectStaging);
}
}
}
}
}

+ 1
- 1
pmapi/src/main/java/com/ningdatech/pmapi/signature/entity/CompanySignature.java View File

@@ -26,7 +26,7 @@ public class CompanySignature implements Serializable {


private String sealSn; private String sealSn;


private Long companyId;
private String organizationCode;


private LocalDateTime createOn; private LocalDateTime createOn;




+ 12
- 0
pmapi/src/main/java/com/ningdatech/pmapi/staging/contants/StagingContant.java View File

@@ -0,0 +1,12 @@
package com.ningdatech.pmapi.staging.contants;

/**
* 项目暂存 静态配置
*/
public interface StagingContant {

class Retry {
public static final Integer MAX_RETRY_TIMES = 10;
}

}

+ 13
- 0
pmapi/src/main/java/com/ningdatech/pmapi/staging/mapper/ProjectStagingMapper.java View File

@@ -0,0 +1,13 @@
package com.ningdatech.pmapi.staging.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ningdatech.pmapi.staging.model.entity.ProjectStaging;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDateTime;

public interface ProjectStagingMapper extends BaseMapper<ProjectStaging> {

Boolean addRetryTimes(@Param("id") Long id, @Param("retryTimes") Integer retryTimes,
@Param("nextRetryTime") LocalDateTime nextRetryTime,@Param("dead") Boolean dead);
}

+ 12
- 0
pmapi/src/main/java/com/ningdatech/pmapi/staging/mapper/ProjectStagingMapper.xml View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ningdatech.pmapi.staging.mapper.ProjectStagingMapper">

<update id="addRetryTimes" >
update nd_project_staging
set retry_times = #{retryTimes},
next_time = #{nextRetryTime},
dead = #{dead}
where id = #{id} and retry_times = #{retryTimes - 1}
</update>
</mapper>

+ 69
- 0
pmapi/src/main/java/com/ningdatech/pmapi/staging/model/entity/ProjectStaging.java View File

@@ -0,0 +1,69 @@
package com.ningdatech.pmapi.staging.model.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
* @Classname ProjectStaging
* @Description
* @Date 2023/2/20 9:40
* @Author PoffyZhang
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@TableName("nd_project_staging")
@ApiModel(value = "ProjectStaging", description = "项目暂存表 扫描进行 状态继续流转 做解耦用")
public class ProjectStaging implements Serializable {

@ApiModelProperty("主键")
@TableId(type = IdType.AUTO)
private Long id;

@ApiModelProperty("项目ID")
private Long projectId;

@ApiModelProperty("项目名称")
private String projectName;

@ApiModelProperty("实例code")
private String instCode;

@ApiModelProperty("流程状态")
private Integer processStatus;

@ApiModelProperty("项目阶段")
private Integer stage;

@ApiModelProperty("项目状态")
private Integer status;

@ApiModelProperty("备注")
private String remark;

@ApiModelProperty("重试次数")
private Integer retryTimes;

@ApiModelProperty("是否死信")
private Boolean dead;

@ApiModelProperty("下次扫描时间")
private LocalDateTime nextTime;

@ApiModelProperty("创建时间")
private LocalDateTime createOn;

@ApiModelProperty("修改时间")
private LocalDateTime updateOn;
}

+ 18
- 0
pmapi/src/main/java/com/ningdatech/pmapi/staging/serivice/IProjectStagingService.java View File

@@ -0,0 +1,18 @@
package com.ningdatech.pmapi.staging.serivice;

import com.baomidou.mybatisplus.extension.service.IService;
import com.ningdatech.pmapi.projectlib.model.entity.Project;
import com.ningdatech.pmapi.staging.model.entity.ProjectStaging;

/**
* @Classname IProjectStagingService
* @Description
* @Date 2023/2/20 10:08
* @Author PoffyZhang
*/
public interface IProjectStagingService extends IService<ProjectStaging> {

Boolean addRetryTimes(ProjectStaging projectStaging);

public Boolean addByProject(Project project,String remark) ;
}

+ 77
- 0
pmapi/src/main/java/com/ningdatech/pmapi/staging/serivice/impl/ProjectStagingServiceImpl.java View File

@@ -0,0 +1,77 @@
package com.ningdatech.pmapi.staging.serivice.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ningdatech.pmapi.projectlib.model.entity.Project;
import com.ningdatech.pmapi.staging.contants.StagingContant;
import com.ningdatech.pmapi.staging.mapper.ProjectStagingMapper;
import com.ningdatech.pmapi.staging.model.entity.ProjectStaging;
import com.ningdatech.pmapi.staging.serivice.IProjectStagingService;
import com.ningdatech.pmapi.staging.utils.ProjectStatusFlowMapUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

/**
* <p>
* 服务实现类
* </p>
*
* @author zpf
* @since 2023-02-18
*/
@Service
@Slf4j
@RequiredArgsConstructor
public class ProjectStagingServiceImpl extends ServiceImpl<ProjectStagingMapper, ProjectStaging> implements IProjectStagingService {

private final ProjectStagingMapper mapper;

private final ProjectStatusFlowMapUtil projectStatusFlowMapUtil;

/**
* 在某些状态节点 增加一个项目到状态暂存库
* @param project
* @return
*/
@Override
public Boolean addByProject(Project project,String remark) {
ProjectStaging projectStaging = ProjectStaging.builder()
.projectId(project.getId())
.projectName(project.getProjectName())
.stage(project.getStage())
.status(project.getStatus())
.createOn(LocalDateTime.now())
.updateOn(LocalDateTime.now())
.instCode(project.getInstCode())
.processStatus(project.getProcessStatus())
.nextTime(LocalDateTime.now())
.retryTimes(0)
.remark(remark)
.build();
return this.save(projectStaging);
}

/**
* 增加 重试次数 和下次扫描时间
* @param projectStaging
* @return
*/
@Override
public Boolean addRetryTimes(ProjectStaging projectStaging) {
Integer retryTimes = projectStaging.getRetryTimes() + 1;
if(!projectStatusFlowMapUtil.intervalTimeMap.containsKey(retryTimes)){
log.info("没有对应重试间隔时间 添加重试信息失败");
return Boolean.FALSE;
}
Integer addSeconds = projectStatusFlowMapUtil.intervalTimeMap.get(retryTimes);
Boolean dead = Boolean.FALSE;
//超过重试最大次数 dead置为 true
if(retryTimes.compareTo(StagingContant.Retry.MAX_RETRY_TIMES) > 0){
dead = Boolean.TRUE;
}
LocalDateTime nextRetryTime = LocalDateTime.now().plusSeconds(addSeconds);
return mapper.addRetryTimes(projectStaging.getId(),retryTimes,nextRetryTime,dead);
}
}

+ 66
- 0
pmapi/src/main/java/com/ningdatech/pmapi/staging/utils/ProjectStatusFlowMapUtil.java View File

@@ -0,0 +1,66 @@
package com.ningdatech.pmapi.staging.utils;

import com.google.common.collect.Maps;
import com.ningdatech.pmapi.projectdeclared.manage.*;
import com.ningdatech.pmapi.projectdeclared.model.dto.DefaultDeclaredDTO;
import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum;
import com.ningdatech.pmapi.projectlib.model.entity.Project;
import com.ningdatech.pmapi.staging.model.entity.ProjectStaging;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.Map;
import java.util.function.Function;

/**
* @Classname ProjectStatusFlowMapUtil
* @Description 状态流转 事件函数MAP
* @Date 2023/2/15 11:19
* @Author PoffyZhang
*/
@Component
@RequiredArgsConstructor
public class ProjectStatusFlowMapUtil {
private final ReviewByProvincialDeptManage provincialDeptManage;

private final ReviewByDeptJointManage reviewByDeptJointManage;

public Map<Integer, Function<Project,Boolean>> statusFlowFunctionMap = Maps.newHashMap();
/**
* key 重试的次数 , value 是增加是描述
*/
public Map<Integer, Integer> intervalTimeMap = Maps.newHashMap();

/**
* 初始化业务分派逻辑,代替了if-else部分
* key: 枚举 状态值
* value: lambda表达式,最终会获取发起实例的函数
*/
@PostConstruct
public void statusFlowFunctionInit(){
//省级部门联审
statusFlowFunctionMap.put(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS.getCode(),
project->provincialDeptManage.startTheProcess(project));
//部门联审
statusFlowFunctionMap.put(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW.getCode(),
project->reviewByDeptJointManage.startTheProcess(project));
}

/**
* 扫描的间隔越来越长 秒数
*/
@PostConstruct
public void intervalTimeMapInit(){
intervalTimeMap.put(1,60 * 2);
intervalTimeMap.put(2,60 * 6);
intervalTimeMap.put(3,60 * 15);
intervalTimeMap.put(4,60 * 30);
intervalTimeMap.put(5,60 * 60);
intervalTimeMap.put(6,60 * 60 * 2);
intervalTimeMap.put(7,60 * 60 * 5);
intervalTimeMap.put(8,60 * 60 * 12);
intervalTimeMap.put(9,60 * 60 * 24);
intervalTimeMap.put(10,60 * 60 * 72);
}
}

+ 6
- 6
pmapi/src/main/java/com/ningdatech/pmapi/sys/controller/NoticeController.java View File

@@ -3,12 +3,12 @@ package com.ningdatech.pmapi.sys.controller;
import com.ningdatech.basic.model.IdVo; import com.ningdatech.basic.model.IdVo;
import com.ningdatech.basic.model.PageVo; import com.ningdatech.basic.model.PageVo;
import com.ningdatech.log.annotation.WebLog; import com.ningdatech.log.annotation.WebLog;
import com.ningdatech.pmapi.sys.manage.NoticeManage;
import com.ningdatech.pmapi.sys.model.req.NoticeListReq; import com.ningdatech.pmapi.sys.model.req.NoticeListReq;
import com.ningdatech.pmapi.sys.model.req.NoticeSaveReq; import com.ningdatech.pmapi.sys.model.req.NoticeSaveReq;
import com.ningdatech.pmapi.sys.model.req.NoticeStatusModifyReq; import com.ningdatech.pmapi.sys.model.req.NoticeStatusModifyReq;
import com.ningdatech.pmapi.sys.model.vo.NoticeDetailVO; import com.ningdatech.pmapi.sys.model.vo.NoticeDetailVO;
import com.ningdatech.pmapi.sys.model.vo.NoticeListItemVO; import com.ningdatech.pmapi.sys.model.vo.NoticeListItemVO;
import com.ningdatech.pmapi.sys.manage.NoticeManage;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
@@ -18,7 +18,7 @@ import javax.validation.Valid;


/** /**
* <p> * <p>
* 系统通知 前端控制器
* 系统公告 前端控制器
* </p> * </p>
* *
* @author WendyYang * @author WendyYang
@@ -33,21 +33,21 @@ public class NoticeController {
private final NoticeManage noticeManage; private final NoticeManage noticeManage;


@PostMapping("/save") @PostMapping("/save")
@ApiOperation("新增通知")
@ApiOperation("新增公告")
@WebLog("新增公告") @WebLog("新增公告")
public IdVo<Long> save(@Valid @RequestBody NoticeSaveReq req) { public IdVo<Long> save(@Valid @RequestBody NoticeSaveReq req) {
return noticeManage.saveOrModify(req); return noticeManage.saveOrModify(req);
} }


@GetMapping("/detail/{id}") @GetMapping("/detail/{id}")
@ApiOperation("通知详情")
@ApiOperation("公告详情")
public NoticeDetailVO save(@PathVariable Long id) { public NoticeDetailVO save(@PathVariable Long id) {
return noticeManage.detail(id); return noticeManage.detail(id);
} }


@PostMapping("/enabled") @PostMapping("/enabled")
@ApiOperation("启用禁用")
@WebLog("启用禁用")
@ApiOperation("启用/禁用")
@WebLog("启用/禁用")
public Boolean save(@Valid @RequestBody NoticeStatusModifyReq req) { public Boolean save(@Valid @RequestBody NoticeStatusModifyReq req) {
return noticeManage.changeEnabled(req); return noticeManage.changeEnabled(req);
} }


+ 19
- 1
pmapi/src/main/java/com/ningdatech/pmapi/user/manage/UserAuthLoginManage.java View File

@@ -39,6 +39,24 @@ public class UserAuthLoginManage {
private final IDingEmployeeInfoService iDingEmployeeInfoService; private final IDingEmployeeInfoService iDingEmployeeInfoService;
private final IUserRoleService iUserRoleService; private final IUserRoleService iUserRoleService;



/**
* 根据用户id 获取用户全量信息
*
* @param userId
* @return
*/
public UserFullInfoDTO getUserFullInfo(Long userId) {
UserInfo userInfo = iUserInfoService.getById(userId);
if (Objects.isNull(userInfo)) {
return null;
}
// 返回用户全量信息
UserFullInfoDTO userFullInfoDTO = new UserFullInfoDTO();
userFullInfoDTOAssembler(userInfo, userFullInfoDTO);
return userFullInfoDTO;
}

/** /**
* 根据用户名获取 * 根据用户名获取
* *
@@ -47,7 +65,7 @@ public class UserAuthLoginManage {
*/ */
public UserFullInfoDTO queryUserInfoInPasswordAuth(String username) { public UserFullInfoDTO queryUserInfoInPasswordAuth(String username) {
// TODO 目前账号密码登陆测试使用 强制用户登录 userId 1L // TODO 目前账号密码登陆测试使用 强制用户登录 userId 1L
UserInfo userInfo = iUserInfoService.getById(1L);
UserInfo userInfo = iUserInfoService.getById(1627599956383571969L);
if (Objects.isNull(userInfo)) { if (Objects.isNull(userInfo)) {
return null; return null;
} }


+ 23
- 3
pmapi/src/main/java/com/ningdatech/pmapi/user/manage/UserInfoManage.java View File

@@ -2,6 +2,7 @@ package com.ningdatech.pmapi.user.manage;


import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ningdatech.basic.exception.BizException; import com.ningdatech.basic.exception.BizException;
@@ -9,7 +10,9 @@ import com.ningdatech.basic.model.PageVo;
import com.ningdatech.pmapi.organization.model.entity.DingEmployeeInfo; import com.ningdatech.pmapi.organization.model.entity.DingEmployeeInfo;
import com.ningdatech.pmapi.organization.service.IDingEmployeeInfoService; import com.ningdatech.pmapi.organization.service.IDingEmployeeInfoService;
import com.ningdatech.pmapi.organization.service.IDingOrganizationService; import com.ningdatech.pmapi.organization.service.IDingOrganizationService;
import com.ningdatech.pmapi.sys.model.entity.Role;
import com.ningdatech.pmapi.sys.model.entity.UserRole; import com.ningdatech.pmapi.sys.model.entity.UserRole;
import com.ningdatech.pmapi.sys.service.IRoleService;
import com.ningdatech.pmapi.sys.service.IUserRoleService; import com.ningdatech.pmapi.sys.service.IUserRoleService;
import com.ningdatech.pmapi.user.constant.UserAvailableEnum; import com.ningdatech.pmapi.user.constant.UserAvailableEnum;
import com.ningdatech.pmapi.user.entity.UserInfo; import com.ningdatech.pmapi.user.entity.UserInfo;
@@ -43,10 +46,12 @@ public class UserInfoManage {
private final IDingEmployeeInfoService iDingEmployeeInfoService; private final IDingEmployeeInfoService iDingEmployeeInfoService;
private final IUserInfoService iUserInfoService; private final IUserInfoService iUserInfoService;
private final IUserRoleService iUserRoleService; private final IUserRoleService iUserRoleService;
private final IRoleService iRoleService;


public PageVo<ResUserInfoListVO> list(ReqUserInfoListPO reqUserInfoListPO) { public PageVo<ResUserInfoListVO> list(ReqUserInfoListPO reqUserInfoListPO) {
LambdaQueryWrapper<DingEmployeeInfo> wrapper = Wrappers.lambdaQuery(DingEmployeeInfo.class) LambdaQueryWrapper<DingEmployeeInfo> wrapper = Wrappers.lambdaQuery(DingEmployeeInfo.class)
.eq(DingEmployeeInfo::getMainJob, "true");
.eq(DingEmployeeInfo::getMainJob, "true")
.eq(StringUtils.isNotBlank(reqUserInfoListPO.getOrgCode()), DingEmployeeInfo::getOrganizationCode, reqUserInfoListPO.getOrgCode());


Page<DingEmployeeInfo> page = iDingEmployeeInfoService.page(new Page<>(reqUserInfoListPO.getPageNumber(), reqUserInfoListPO.getPageSize()), wrapper); Page<DingEmployeeInfo> page = iDingEmployeeInfoService.page(new Page<>(reqUserInfoListPO.getPageNumber(), reqUserInfoListPO.getPageSize()), wrapper);
List<DingEmployeeInfo> records = page.getRecords(); List<DingEmployeeInfo> records = page.getRecords();
@@ -97,7 +102,21 @@ public class UserInfoManage {
resUserDetailVO.setUserId(userInfo.getId()); resUserDetailVO.setUserId(userInfo.getId());
resUserDetailVO.setPhoneNo(userInfo.getMobile()); resUserDetailVO.setPhoneNo(userInfo.getMobile());
resUserDetailVO.setStatus(userInfo.getAvailable()); resUserDetailVO.setStatus(userInfo.getAvailable());
resUserDetailVO.setUserRoleInfoList(new ArrayList<>());

// 装配用户角色信息列表
List<UserRole> userRoleList = iUserRoleService.list(Wrappers.lambdaQuery(UserRole.class).eq(UserRole::getUserId, userId));
List<UserRoleVO> userRoleInfoList = new ArrayList<>();
if (CollUtil.isNotEmpty(userRoleList)) {
List<Long> roleIdList = userRoleList.stream().map(UserRole::getRoleId).collect(Collectors.toList());
List<Role> roleList = iRoleService.list(Wrappers.lambdaQuery(Role.class).in(Role::getId, roleIdList));
userRoleInfoList = roleList.stream().map(r -> {
UserRoleVO userRoleVO = new UserRoleVO();
userRoleVO.setId(r.getId());
userRoleVO.setName(r.getName());
return userRoleVO;
}).collect(Collectors.toList());
}
resUserDetailVO.setUserRoleInfoList(userRoleInfoList);
return resUserDetailVO; return resUserDetailVO;
} }


@@ -127,7 +146,8 @@ public class UserInfoManage {


} }


private Long generateUserId(String employeeCode) {
@Transactional(rollbackFor = Exception.class)
public Long generateUserId(String employeeCode) {
UserInfo userInfo = iUserInfoService.getOne(Wrappers.lambdaQuery(UserInfo.class) UserInfo userInfo = iUserInfoService.getOne(Wrappers.lambdaQuery(UserInfo.class)
.eq(UserInfo::getEmployeeCode, employeeCode)); .eq(UserInfo::getEmployeeCode, employeeCode));
if (Objects.isNull(userInfo)) { if (Objects.isNull(userInfo)) {


+ 3
- 0
pmapi/src/main/java/com/ningdatech/pmapi/user/model/po/ReqUserInfoListPO.java View File

@@ -25,6 +25,9 @@ public class ReqUserInfoListPO extends PagePo {
@ApiModelProperty("所在单位(主职)") @ApiModelProperty("所在单位(主职)")
private String orgName; private String orgName;


@ApiModelProperty("所在单位Code(主职)")
private String orgCode;

@ApiModelProperty("所属区域") @ApiModelProperty("所属区域")
private Long regionId; private Long regionId;




+ 5
- 4
pmapi/src/main/java/com/ningdatech/pmapi/user/util/LoginUserUtil.java View File

@@ -1,10 +1,11 @@
package com.ningdatech.pmapi.user.util; package com.ningdatech.pmapi.user.util;


import com.ningdatech.basic.auth.AbstractLoginUserUtil; import com.ningdatech.basic.auth.AbstractLoginUserUtil;
import com.ningdatech.pmapi.sys.model.entity.Role;
import com.ningdatech.pmapi.user.security.auth.model.UserInfoDetails; import com.ningdatech.pmapi.user.security.auth.model.UserInfoDetails;


import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;




/** /**
@@ -19,9 +20,9 @@ public class LoginUserUtil extends AbstractLoginUserUtil {
} }


public static List<Long> getRoleIdList() { public static List<Long> getRoleIdList() {
List<Long> roleIdList = new ArrayList<>();
roleIdList.add(1L);
return roleIdList;
UserInfoDetails userInfoDetails = loginUserDetail();
List<Role> userRoleList = userInfoDetails.getUserRoleList();
return userRoleList.stream().map(Role::getId).collect(Collectors.toList());
} }


} }

+ 1
- 0
pmapi/src/main/resources/security/auth-dev.yml View File

@@ -22,6 +22,7 @@ security:
- /oa/** - /oa/**
- /wflow/** - /wflow/**
- /sys/** - /sys/**
- /api/v1/user-info/**
ignore-csrf-urls: ignore-csrf-urls:
- /api/v1/user/auth/** - /api/v1/user/auth/**
- /v2/api-docs - /v2/api-docs


+ 0
- 11
pmapi/src/test/resources/application-dev.yml View File

@@ -87,17 +87,6 @@ spring:
wall: wall:
config: config:
multi-statement-allow: true multi-statement-allow: true
# rabbitmq 配置信息
rabbitmq:
host: 110.40.194.60
port: 5672
username: admin
password: admin
#1、确保消息从发送端到服务端投递可靠(分为以下两个步骤)
#1.1、确认消息已发送到交换机(Exchange) 可以把publisher-confirms: true 替换为 publisher-confirm-type: correlate
publisher-confirm-type: correlated
#1.2、确认消息从交换机中到队列中
publisher-returns: true


mybatis-plus: mybatis-plus:
configuration: configuration:


+ 0
- 5
pom.xml View File

@@ -150,11 +150,6 @@
<version>1.0.0</version> <version>1.0.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.ningdatech</groupId>
<artifactId>nd-rabbitmq-starter</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>joda-time</groupId> <groupId>joda-time</groupId>
<artifactId>joda-time</artifactId> <artifactId>joda-time</artifactId>
<version>2.10.6</version> <version>2.10.6</version>


Loading…
Cancel
Save