@@ -105,4 +105,8 @@ public class BizUtils { | |||
}))); | |||
} | |||
public static String inSqlJoin(List<String> strings) { | |||
return strings.stream().map(w -> "'" + w + "'").collect(Collectors.joining(StrPool.COMMA, StrPool.LEFT_BRACKET, StrPool.RIGHT_BRACKET)); | |||
} | |||
} |
@@ -4,6 +4,7 @@ import com.ningdatech.basic.util.SpringUtils; | |||
import com.ningdatech.pmapi.datascope.model.DataScopeDTO; | |||
import lombok.RequiredArgsConstructor; | |||
import java.io.Serializable; | |||
import java.util.Map; | |||
import java.util.Optional; | |||
@@ -16,7 +17,7 @@ import java.util.Optional; | |||
* @since 2022/1/9 23:28 | |||
*/ | |||
@RequiredArgsConstructor | |||
public class DataScopeContext { | |||
public class DataScopeContext implements Serializable { | |||
private static final String WARN_MSG = "请先创建数据权限[%s]的实现类,使其实现 DataScopeProvider"; | |||
@@ -1,8 +1,13 @@ | |||
package com.ningdatech.pmapi.expert.service; | |||
import cn.hutool.core.collection.CollUtil; | |||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||
import com.baomidou.mybatisplus.extension.service.IService; | |||
import com.ningdatech.basic.util.CollUtils; | |||
import com.ningdatech.pmapi.expert.entity.ExpertUserFullInfo; | |||
import java.util.Collection; | |||
import java.util.List; | |||
/** | |||
@@ -33,7 +38,6 @@ public interface IExpertUserFullInfoService extends IService<ExpertUserFullInfo> | |||
List<ExpertUserFullInfo> listByUserId(List<Long> userId); | |||
/** | |||
* 批量查询专家用户信息 | |||
* | |||
@@ -42,4 +46,12 @@ public interface IExpertUserFullInfoService extends IService<ExpertUserFullInfo> | |||
*/ | |||
List<ExpertUserFullInfo> listByUserIds(List<Long> userIds); | |||
default List<String> listCompanyUniqCodeByUserIds(Collection<Long> userIds) { | |||
LambdaQueryWrapper<ExpertUserFullInfo> query = Wrappers | |||
.lambdaQuery(ExpertUserFullInfo.class) | |||
.select(ExpertUserFullInfo::getCompanyUniqCode) | |||
.in(ExpertUserFullInfo::getUserId, userIds); | |||
return CollUtils.fieldList(list(query), ExpertUserFullInfo::getCompanyUniqCode); | |||
} | |||
} |
@@ -1,8 +1,6 @@ | |||
package com.ningdatech.pmapi.leave.entity.domain; | |||
import com.baomidou.mybatisplus.annotation.IdType; | |||
import com.baomidou.mybatisplus.annotation.TableId; | |||
import com.baomidou.mybatisplus.annotation.TableName; | |||
import com.baomidou.mybatisplus.annotation.*; | |||
import io.swagger.annotations.ApiModel; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.Data; | |||
@@ -48,15 +46,19 @@ public class ExpertLeave implements Serializable { | |||
private String creator; | |||
@ApiModelProperty("创建人") | |||
@TableField(fill = FieldFill.INSERT_UPDATE) | |||
private Long createBy; | |||
@ApiModelProperty("创建时间") | |||
@TableField(fill = FieldFill.INSERT) | |||
private LocalDateTime createOn; | |||
@ApiModelProperty("修改人") | |||
@TableField(fill = FieldFill.INSERT_UPDATE) | |||
private Long updateBy; | |||
@ApiModelProperty("修改时间") | |||
@TableField(fill = FieldFill.INSERT_UPDATE) | |||
private LocalDateTime updateOn; | |||
@ApiModelProperty("请假开始时间") | |||
@@ -75,9 +77,4 @@ public class ExpertLeave implements Serializable { | |||
private Integer status; | |||
public void setUpdateAndCreate(Long createBy, LocalDateTime createOn) { | |||
this.updateBy = this.createBy = createBy; | |||
this.updateOn = this.createOn = createOn; | |||
} | |||
} |
@@ -150,7 +150,7 @@ public class LeaveManage { | |||
leave.setType(po.getType()); | |||
leave.setRemark(po.getPostscript()); | |||
leave.setLeaveUserId(leaveUserId); | |||
leave.setUpdateAndCreate(applyUserId, now); | |||
leave.setCreator(LoginUserUtil.getUsername()); | |||
List<KeyValDTO<LocalDateTime, LocalDateTime>> leaveDetailTimes = new ArrayList<>(); | |||
if (type.equals(LeaveTypeEnum.FIXED_TERM) || type.equals(LeaveTypeEnum.LONG_TERM)) { | |||
boolean fixedTerm = CollUtil.isNotEmpty(po.getFixedType()); | |||
@@ -70,6 +70,9 @@ public class ExpertInviteManage { | |||
@Value("#{randomInviteProperties.recentMeetingCount}") | |||
private Integer recentMeetingCount; | |||
@Value("#{randomInviteProperties.recentDays}") | |||
private Integer recentDays; | |||
private static final Predicate<Collection<?>> COLL_EMPTY = (coll) -> coll != null && coll.isEmpty(); | |||
private LambdaQueryWrapper<ExpertUserFullInfo> buildBaseExpertQuery() { | |||
@@ -83,6 +86,36 @@ public class ExpertInviteManage { | |||
.eq(ExpertUserFullInfo::getExpertAccountStatus, ExpertAccountStatusEnum.AVAILABLE.getKey()); | |||
} | |||
private void buildAvoidCompanyAndBusinessStrip(LambdaQueryWrapper<ExpertUserFullInfo> query, List<String> units, List<String> strips) { | |||
if (CollUtil.isNotEmpty(units)) { | |||
String unitStr = BizUtils.inSqlJoin(units); | |||
query.notExists("select 1 from expert_avoid_company eac where eac.user_id = nd_expert_user_full_info.user_id" + | |||
" and company_uniq_code in " + unitStr); | |||
} | |||
if (CollUtil.isNotEmpty(strips)) { | |||
String orgStr = BizUtils.inSqlJoin(strips); | |||
query.notExists("select 1 from expert_gov_business_strip egbs where egbs.expert_user_id = nd_expert_user_full_info.user_id" + | |||
" and business_strip_code in " + orgStr); | |||
} | |||
} | |||
/** | |||
* 获取一周内被抽中并同意参会的专家ID | |||
* | |||
* @param agreeCnt 一周内被抽中并同意参会次数 | |||
* @param sTime 会议开始时间 | |||
* @param days 天数 | |||
* @return java.util.List<java.lang.Long> | |||
* @author WendyYang | |||
**/ | |||
private List<Long> listAgreedUserIdByRecentMeetings(int agreeCnt, int days, LocalDateTime sTime) { | |||
if (agreeCnt == 0 || days == 0) { | |||
return Collections.emptyList(); | |||
} | |||
LocalDateTime beginLimit = sTime.minusDays(days); | |||
return meetingExpertService.listAgreeExpertIdByRecentDaysAndAgreeCount(agreeCnt, beginLimit, sTime); | |||
} | |||
/** | |||
* 增加专家层级限制 | |||
* | |||
@@ -249,13 +282,13 @@ public class ExpertInviteManage { | |||
* | |||
* @param avoidRule 回避信息 | |||
* @param randomRule 抽取规则 | |||
* @param appointExpertIds 指定抽取专家ID | |||
* @param invitedExpertIds 指定抽取专家ID | |||
* @return 满足抽取条件的专家 | |||
* @author WendyYang | |||
**/ | |||
public ExpertChooseDTO expertInviteByRandomRule(AvoidRuleDTO avoidRule, | |||
RandomInviteRuleDTO randomRule, | |||
List<Long> appointExpertIds, | |||
List<Long> invitedExpertIds, | |||
LocalDateTime sTime, | |||
LocalDateTime eTime) { | |||
ExpertChooseDTO result = new ExpertChooseDTO(new ArrayList<>(), 0); | |||
@@ -265,17 +298,19 @@ public class ExpertInviteManage { | |||
} | |||
boolean avoidExpert = CollUtil.isNotEmpty(avoidRule.getExpertIds()); | |||
boolean avoidCompany = CollUtil.isNotEmpty(avoidRule.getAvoidUnitIdList()); | |||
Set<String> tmpAvoidCompany = new HashSet<>(); | |||
Set<String> avoidCompanyUniqCodes = new HashSet<>(); | |||
if (avoidCompany) { | |||
tmpAvoidCompany.addAll(avoidRule.getAvoidUnitIdList()); | |||
avoidCompanyUniqCodes.addAll(avoidRule.getAvoidUnitIdList()); | |||
} | |||
if (CollUtil.isNotEmpty(invitedExpertIds)) { | |||
List<String> tmpCompanyUniqCodes = expertUserFullInfoService.listCompanyUniqCodeByUserIds(invitedExpertIds); | |||
avoidCompanyUniqCodes.addAll(tmpCompanyUniqCodes); | |||
} | |||
// 回避信息 | |||
LambdaQueryWrapper<ExpertUserFullInfo> query = buildBaseExpertQuery(); | |||
query.notIn(!tmpAvoidCompany.isEmpty(), ExpertUserFullInfo::getCompanyUniqCode, tmpAvoidCompany); | |||
if (avoidCompany) { | |||
query.notExists("select 1 from expert_avoid_company eac where eac.user_id = nd_expert_user_full_info.user_id" + | |||
" and company_uniq_code in ({0})", CollUtils.joinByComma(avoidRule.getAvoidUnitIdList())); | |||
} | |||
query.notIn(!avoidCompanyUniqCodes.isEmpty(), ExpertUserFullInfo::getCompanyUniqCode, avoidCompanyUniqCodes); | |||
// 处理回避单位与回避条线 | |||
buildAvoidCompanyAndBusinessStrip(query, avoidRule.getAvoidUnitIdList(), avoidRule.getAvoidOrgIdList()); | |||
Set<Long> expertIdsIn = new HashSet<>(); | |||
Set<Long> expertIdsNotIn = new HashSet<>(); | |||
if (CollUtil.isNotEmpty(merge.getExpertIdsIn())) { | |||
@@ -283,6 +318,12 @@ public class ExpertInviteManage { | |||
} else if (CollUtil.isNotEmpty(merge.getExpertIdsNotIn())) { | |||
expertIdsNotIn.addAll(merge.getExpertIdsNotIn()); | |||
} | |||
// 处理回避专家次数 | |||
if (avoidRule.getWeekInviteCount() != null) { | |||
Integer weekInviteCount = avoidRule.getWeekInviteCount(); | |||
List<Long> tmpExpertIdsNotIn = listAgreedUserIdByRecentMeetings(weekInviteCount, recentDays, sTime); | |||
expertIdsNotIn.addAll(tmpExpertIdsNotIn); | |||
} | |||
// 处理专家层级 | |||
addRegionLimit(query, randomRule); | |||
if (!expertIdsIn.isEmpty()) { | |||
@@ -293,8 +334,8 @@ public class ExpertInviteManage { | |||
return result; | |||
} | |||
} | |||
if (CollUtil.isNotEmpty(appointExpertIds)) { | |||
expertIdsIn.removeIf(appointExpertIds::contains); | |||
if (CollUtil.isNotEmpty(invitedExpertIds)) { | |||
expertIdsIn.removeIf(invitedExpertIds::contains); | |||
if (expertIdsIn.isEmpty()) { | |||
return result; | |||
} | |||
@@ -305,8 +346,8 @@ public class ExpertInviteManage { | |||
if (expertIdsIn.isEmpty()) { | |||
return result; | |||
} | |||
} else if (avoidExpert || CollUtil.isNotEmpty(appointExpertIds)) { | |||
Set<Long> tmpExpert = expertInviteHelper.getAvoidExpert(appointExpertIds, avoidRule, sTime, eTime); | |||
} else if (avoidExpert || CollUtil.isNotEmpty(invitedExpertIds)) { | |||
Set<Long> tmpExpert = expertInviteHelper.getAvoidExpert(invitedExpertIds, avoidRule, sTime, eTime); | |||
expertIdsNotIn.addAll(tmpExpert); | |||
} else { | |||
Set<Long> tmpNotInUserIds = expertInviteHelper.listExpertLeaveOrInvited(sTime, eTime); | |||
@@ -365,8 +406,14 @@ public class ExpertInviteManage { | |||
LambdaQueryWrapper<ExpertUserFullInfo> query = buildBaseExpertQuery(); | |||
// 设置回避单位 | |||
Set<String> notInCompanyUniqCodeList = new HashSet<>(avoidRule.getAvoidUnitIdList()); | |||
query.notExists("select 1 from expert_avoid_company eac where eac.user_id = nd_expert_user_full_info.user_id" + | |||
" and company_uniq_code in ({0})", CollUtils.joinByComma(avoidRule.getAvoidUnitIdList())); | |||
// 处理回避单位与回避条线 | |||
buildAvoidCompanyAndBusinessStrip(query, avoidRule.getAvoidUnitIdList(), avoidRule.getAvoidOrgIdList()); | |||
// 处理回避专家次数 | |||
if (avoidRule.getWeekInviteCount() != null) { | |||
Integer weekInviteCount = avoidRule.getWeekInviteCount(); | |||
List<Long> tmpExpertIdsNotIn = listAgreedUserIdByRecentMeetings(weekInviteCount, recentDays, msTime); | |||
expertIdsNotIn.addAll(tmpExpertIdsNotIn); | |||
} | |||
// 处理专家层级 | |||
addRegionLimit(query, randomRule); | |||
@@ -9,6 +9,7 @@ import com.ningdatech.pmapi.meeting.entity.enumeration.ExpertAttendStatusEnum; | |||
import com.ningdatech.pmapi.meeting.entity.req.ReviewProjectListReq; | |||
import org.apache.ibatis.annotations.Param; | |||
import java.time.LocalDateTime; | |||
import java.util.Collection; | |||
import java.util.List; | |||
@@ -62,6 +63,19 @@ public interface MeetingExpertMapper extends BaseMapper<MeetingExpert> { | |||
@Param("meetingIds") Collection<Long> meetingIds); | |||
/** | |||
* 查询时间窗口之内参与会议不超过{@code agreeCount}次的专家ID | |||
* | |||
* @param agreeCount 参与次数(包含) | |||
* @param startTime 开始时间 | |||
* @param endTime 结束时间 | |||
* @return 专家ID集合 | |||
* @author WendyYang | |||
**/ | |||
List<Long> listAgreeExpertIdByRecentDaysAndAgreeCount(@Param("agreeCount") Integer agreeCount, | |||
@Param("startTime") LocalDateTime startTime, | |||
@Param("endTime") LocalDateTime endTime); | |||
/** | |||
* 根据会议ID与参与状态统计专家数量 | |||
* | |||
* @param status 会议状态 | |||
@@ -50,6 +50,15 @@ | |||
</if> | |||
</select> | |||
<select id="listAgreeExpertIdByRecentDaysAndAgreeCount" resultType="long"> | |||
SELECT expert_id FROM (SELECT ROW_NUMBER() OVER ( PARTITION BY expert_id, meeting_id ORDER BY update_on DESC ) | |||
rowNumber,expert_id, status FROM meeting_expert | |||
where meeting_id in (select id from meeting m where m.status = 1 | |||
and ((m.start_time >= #{startTime} and m.start_time < #{endTime}) | |||
or (m.end_time >= #{startTime} and m.end_time < #{endTime})) )) em | |||
WHERE rowNumber = 1 and status = 3 group by expert_id having count(1) <= #{agreeCount} | |||
</select> | |||
<select id="countExpertByStatusAndMeetingId" | |||
resultType="int"> | |||
SELECT count(1) FROM (SELECT ROW_NUMBER() OVER ( PARTITION BY expert_id, meeting_id ORDER BY update_on DESC ) | |||
@@ -9,8 +9,8 @@ import com.ningdatech.pmapi.meeting.entity.dto.ReviewProjectDTO; | |||
import com.ningdatech.pmapi.meeting.entity.enumeration.ExpertAttendStatusEnum; | |||
import com.ningdatech.pmapi.meeting.entity.enumeration.ExpertInviteTypeEnum; | |||
import com.ningdatech.pmapi.meeting.entity.req.ReviewProjectListReq; | |||
import org.apache.ibatis.annotations.Param; | |||
import java.time.LocalDateTime; | |||
import java.util.Collection; | |||
import java.util.Collections; | |||
import java.util.List; | |||
@@ -155,4 +155,6 @@ public interface IMeetingExpertService extends IService<MeetingExpert> { | |||
**/ | |||
Page<ReviewProjectDTO> pageReviewProjectList(ReviewProjectListReq req); | |||
List<Long> listAgreeExpertIdByRecentDaysAndAgreeCount(int agreeCount, LocalDateTime sTime, LocalDateTime eTime); | |||
} |
@@ -19,6 +19,7 @@ import com.ningdatech.pmapi.meeting.service.IMeetingExpertService; | |||
import lombok.RequiredArgsConstructor; | |||
import org.springframework.stereotype.Service; | |||
import java.time.LocalDateTime; | |||
import java.util.Collection; | |||
import java.util.List; | |||
import java.util.Map; | |||
@@ -134,4 +135,9 @@ public class MeetingExpertServiceImpl extends ServiceImpl<MeetingExpertMapper, M | |||
return baseMapper.pageReviewProjectList(req.page(), req); | |||
} | |||
@Override | |||
public List<Long> listAgreeExpertIdByRecentDaysAndAgreeCount(int agreeCount, LocalDateTime sTime, LocalDateTime eTime) { | |||
return baseMapper.listAgreeExpertIdByRecentDaysAndAgreeCount(agreeCount, sTime, eTime); | |||
} | |||
} |
@@ -207,7 +207,7 @@ public class ExpertCallResultRewriteTask { | |||
status = REFUSED; | |||
} | |||
} catch (Exception e) { | |||
log.error("获取电话回调结果异常", e); | |||
log.error("获取电话回调结果异常{}", mrd, e); | |||
status = UNANSWERED; | |||
} | |||
} else { | |||
@@ -42,4 +42,10 @@ public class RandomInviteProperties { | |||
* 近期会议数量(以此来降低专家抽中间隔) | |||
*/ | |||
private Integer recentMeetingCount = 5; | |||
/** | |||
* 参会次数限制天数 | |||
*/ | |||
private Integer recentDays = 7; | |||
} |
@@ -28,6 +28,9 @@ import com.ningdatech.pmapi.projectlib.model.req.ProjectListReq; | |||
import com.ningdatech.pmapi.projectlib.model.vo.ProjectLibListItemVO; | |||
import com.ningdatech.pmapi.projectlib.service.IProjectInstService; | |||
import com.ningdatech.pmapi.projectlib.service.IProjectService; | |||
import com.ningdatech.pmapi.staging.enums.MsgTypeEnum; | |||
import com.ningdatech.pmapi.sys.manage.NoticeManage; | |||
import com.ningdatech.pmapi.todocenter.constant.WorkNoticeContant; | |||
import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO; | |||
import com.ningdatech.pmapi.user.util.LoginUserUtil; | |||
import com.wflow.bean.entity.WflowModels; | |||
@@ -80,6 +83,8 @@ public class ConstructionPlanManage { | |||
private final DefaultDeclaredProjectManage declaredProjectManage; | |||
private final DefaultDeclaredProjectManage defaultDeclaredProjectManage; | |||
private final NoticeManage noticeManage; | |||
/** | |||
* 建设方案 | |||
* | |||
@@ -133,6 +138,10 @@ public class ConstructionPlanManage { | |||
//保存建设项目 | |||
modifyProject(projectInfo, instanceId, projectInfo.getConstructionPlanFile()); | |||
//发送给第一个审批人消息 | |||
noticeManage.sendFirtUser(projectInfo,model.getFormName(),instanceId, | |||
WorkNoticeContant.PASS_MSG_TEMPLATE, MsgTypeEnum.PROJECT_REVIEW); | |||
return instanceId; | |||
} | |||
@@ -11,7 +11,6 @@ import com.ningdatech.basic.function.VUtils; | |||
import com.ningdatech.basic.model.PageVo; | |||
import com.ningdatech.basic.util.CollUtils; | |||
import com.ningdatech.basic.util.NdDateUtils; | |||
import com.ningdatech.pmapi.common.constant.CommonConst; | |||
import com.ningdatech.pmapi.common.constant.RegionConst; | |||
import com.ningdatech.pmapi.common.enumeration.CommonEnum; | |||
import com.ningdatech.pmapi.common.enumeration.ProjectProcessStageEnum; | |||
@@ -19,44 +18,34 @@ import com.ningdatech.pmapi.common.helper.RegionCacheHelper; | |||
import com.ningdatech.pmapi.common.helper.UserInfoHelper; | |||
import com.ningdatech.pmapi.common.util.ExcelDownUtil; | |||
import com.ningdatech.pmapi.common.util.ExcelExportStyle; | |||
import com.ningdatech.pmapi.organization.model.entity.DingOrganization; | |||
import com.ningdatech.pmapi.organization.service.IDingOrganizationService; | |||
import com.ningdatech.pmapi.projectdeclared.model.dto.*; | |||
import com.ningdatech.pmapi.projectdeclared.model.entity.ProjectDraft; | |||
import com.ningdatech.pmapi.projectdeclared.model.vo.ProjectDraftVO; | |||
import com.ningdatech.pmapi.projectdeclared.service.IProjectDraftService; | |||
import com.ningdatech.pmapi.projectdeclared.utils.GenerateProjectCodeUtil; | |||
import com.ningdatech.pmapi.projectlib.enumeration.ProjectRenewalApprovalStatusEnum; | |||
import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum; | |||
import com.ningdatech.pmapi.projectlib.enumeration.ProjectTypeEnum; | |||
import com.ningdatech.pmapi.projectlib.helper.ProjectHelper; | |||
import com.ningdatech.pmapi.projectlib.manage.ProjectLibManage; | |||
import com.ningdatech.pmapi.projectlib.model.dto.ProjectDTO; | |||
import com.ningdatech.pmapi.projectlib.model.dto.ProjectRenewalExportDTO; | |||
import com.ningdatech.pmapi.projectlib.model.entity.Project; | |||
import com.ningdatech.pmapi.projectlib.model.entity.ProjectApplication; | |||
import com.ningdatech.pmapi.projectlib.model.entity.ProjectInst; | |||
import com.ningdatech.pmapi.projectlib.model.po.ProjectRenewalFundDeclarationPO; | |||
import com.ningdatech.pmapi.projectlib.model.req.ProjectListReq; | |||
import com.ningdatech.pmapi.projectlib.model.vo.ProjectLibListItemVO; | |||
import com.ningdatech.pmapi.projectlib.service.IProjectApplicationService; | |||
import com.ningdatech.pmapi.projectlib.service.IProjectInstService; | |||
import com.ningdatech.pmapi.projectlib.service.IProjectService; | |||
import com.ningdatech.pmapi.staging.enums.MsgTypeEnum; | |||
import com.ningdatech.pmapi.sys.manage.NoticeManage; | |||
import com.ningdatech.pmapi.todocenter.constant.WorkNoticeContant; | |||
import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO; | |||
import com.ningdatech.pmapi.user.security.auth.model.UserInfoDetails; | |||
import com.ningdatech.pmapi.user.util.LoginUserUtil; | |||
import com.wflow.bean.entity.WflowModels; | |||
import com.wflow.bean.entity.WflowOrgModels; | |||
import com.wflow.enums.OrgTypeEnum; | |||
import com.wflow.enums.ProcessDefTypeEnum; | |||
import com.wflow.exception.BusinessException; | |||
import com.wflow.service.OrgProcdefService; | |||
import com.wflow.workflow.bean.dto.OrgInfoDTO; | |||
import com.wflow.workflow.bean.vo.ProcessStartParamsVo; | |||
import com.wflow.workflow.service.ProcessInstanceService; | |||
import com.wflow.workflow.service.ProcessModelService; | |||
import lombok.AllArgsConstructor; | |||
import lombok.NoArgsConstructor; | |||
import lombok.RequiredArgsConstructor; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.apache.commons.lang3.StringUtils; | |||
@@ -96,7 +85,7 @@ public class DeclaredProjectManage { | |||
private final DefaultDeclaredProjectManage defaultDeclaredProjectManage; | |||
private final ProjectLibManage projectlibManager; | |||
private final NoticeManage noticeManage; | |||
private final UserInfoHelper userInfoHelper; | |||
@@ -179,6 +168,10 @@ public class DeclaredProjectManage { | |||
projectDraftService.removeById(projectInfo.getDraftId()); | |||
} | |||
//发送给第一个审批人消息 | |||
noticeManage.sendFirtUser(project,model.getFormName(),instanceId, | |||
WorkNoticeContant.PASS_MSG_TEMPLATE, MsgTypeEnum.PROJECT_REVIEW); | |||
return instanceId; | |||
} | |||
@@ -243,6 +236,10 @@ public class DeclaredProjectManage { | |||
//保存项目 | |||
saveOrUpdateProject(projectDto,instanceId,employeeCode); | |||
//发送给第一个审批人消息 | |||
noticeManage.sendFirtUser(project,model.getFormName(),instanceId, | |||
WorkNoticeContant.PASS_MSG_TEMPLATE, MsgTypeEnum.PROJECT_REVIEW); | |||
return instanceId; | |||
} | |||
@@ -1,9 +1,6 @@ | |||
package com.ningdatech.pmapi.projectdeclared.manage; | |||
import cn.hutool.core.collection.CollUtil; | |||
import com.alibaba.excel.EasyExcel; | |||
import com.alibaba.fastjson.JSON; | |||
import com.alibaba.fastjson.TypeReference; | |||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | |||
@@ -17,16 +14,12 @@ import com.ningdatech.pmapi.common.helper.UserInfoHelper; | |||
import com.ningdatech.pmapi.common.statemachine.util.StateMachineUtils; | |||
import com.ningdatech.pmapi.common.util.ExcelDownUtil; | |||
import com.ningdatech.pmapi.common.util.ExcelExportStyle; | |||
import com.ningdatech.pmapi.datascope.model.DataScopeDTO; | |||
import com.ningdatech.pmapi.datascope.utils.DataScopeUtil; | |||
import com.ningdatech.pmapi.projectdeclared.model.dto.DefaultDeclaredDTO; | |||
import com.ningdatech.pmapi.projectdeclared.model.dto.PretrialDeclaredExportDTO; | |||
import com.ningdatech.pmapi.projectdeclared.model.dto.ProjectConditionDTO; | |||
import com.ningdatech.pmapi.projectdeclared.model.req.PrequalificationDeclaredListReq; | |||
import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum; | |||
import com.ningdatech.pmapi.projectlib.enumeration.ProjectTypeEnum; | |||
import com.ningdatech.pmapi.projectlib.helper.ProjectHelper; | |||
import com.ningdatech.pmapi.projectlib.manage.ProjectLibManage; | |||
import com.ningdatech.pmapi.projectlib.model.dto.ProjectDTO; | |||
import com.ningdatech.pmapi.projectlib.model.entity.Project; | |||
import com.ningdatech.pmapi.projectlib.model.entity.ProjectInst; | |||
@@ -34,8 +27,11 @@ import com.ningdatech.pmapi.projectlib.model.req.ProjectListReq; | |||
import com.ningdatech.pmapi.projectlib.model.vo.ProjectLibListItemVO; | |||
import com.ningdatech.pmapi.projectlib.service.IProjectInstService; | |||
import com.ningdatech.pmapi.projectlib.service.IProjectService; | |||
import com.ningdatech.pmapi.staging.enums.MsgTypeEnum; | |||
import com.ningdatech.pmapi.staging.service.IProjectStagingService; | |||
import com.ningdatech.pmapi.sys.manage.NoticeManage; | |||
import com.ningdatech.pmapi.todocenter.constant.TodoCenterContant; | |||
import com.ningdatech.pmapi.todocenter.constant.WorkNoticeContant; | |||
import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO; | |||
import com.ningdatech.pmapi.user.util.LoginUserUtil; | |||
import com.wflow.bean.entity.WflowModels; | |||
@@ -83,6 +79,8 @@ public class PrequalificationDeclaredProjectManage { | |||
private final IProjectInstService projectInstService; | |||
private final NoticeManage noticeManage; | |||
/** | |||
* 提交预审 | |||
* @param dto | |||
@@ -112,7 +110,9 @@ public class PrequalificationDeclaredProjectManage { | |||
.throwMessage("提交失败 该项目不是 待预审状态(省级部门联审成功)或者未立项阶段"); | |||
//使用状态机 进入下一步 看看需不需要走省级审批 放入文件 | |||
projectInfo.setHigherLineSuperOrgReviewComments(projectDto.getHigherLineSuperOrgReviewComments()); | |||
if(StringUtils.isNotBlank(projectDto.getHigherLineSuperOrgReviewComments())){ | |||
projectInfo.setHigherLineSuperOrgReviewComments(projectDto.getHigherLineSuperOrgReviewComments()); | |||
} | |||
stateMachineUtils.pass(projectInfo); | |||
String instanceId = null; | |||
//如果是省级部门 需要联审的(申报金额大于1000万 并且是市级项目) | |||
@@ -194,6 +194,10 @@ public class PrequalificationDeclaredProjectManage { | |||
//保存预审项目 | |||
preModifyProject(projectInfo, instanceId); | |||
//发送给第一个审批人消息 | |||
noticeManage.sendFirtUser(projectInfo,model.getFormName(),instanceId, | |||
WorkNoticeContant.PASS_MSG_TEMPLATE, MsgTypeEnum.PROJECT_REVIEW); | |||
return instanceId; | |||
} | |||
@@ -1,17 +1,17 @@ | |||
package com.ningdatech.pmapi.projectdeclared.manage; | |||
import com.alibaba.fastjson.JSON; | |||
import com.alibaba.fastjson.TypeReference; | |||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||
import com.google.common.collect.Maps; | |||
import com.ningdatech.basic.function.VUtils; | |||
import com.ningdatech.pmapi.common.enumeration.ProjectProcessStageEnum; | |||
import com.ningdatech.pmapi.projectdeclared.model.dto.ProjectConditionDTO; | |||
import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum; | |||
import com.ningdatech.pmapi.projectlib.model.entity.Project; | |||
import com.ningdatech.pmapi.projectlib.model.entity.ProjectInst; | |||
import com.ningdatech.pmapi.projectlib.service.IProjectInstService; | |||
import com.ningdatech.pmapi.projectlib.service.IProjectService; | |||
import com.ningdatech.pmapi.staging.enums.MsgTypeEnum; | |||
import com.ningdatech.pmapi.sys.manage.NoticeManage; | |||
import com.ningdatech.pmapi.todocenter.constant.WorkNoticeContant; | |||
import com.wflow.bean.entity.WflowModels; | |||
import com.wflow.exception.BusinessException; | |||
import com.wflow.workflow.bean.dto.OrgInfoDTO; | |||
@@ -20,10 +20,8 @@ import com.wflow.workflow.service.ProcessInstanceService; | |||
import com.wflow.workflow.service.ProcessModelService; | |||
import lombok.RequiredArgsConstructor; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.beans.BeanUtils; | |||
import org.springframework.stereotype.Component; | |||
import org.springframework.transaction.annotation.Transactional; | |||
import java.time.LocalDateTime; | |||
import java.util.Collections; | |||
import java.util.Map; | |||
@@ -50,6 +48,8 @@ public class ReviewByDeptJointManage { | |||
private final DefaultDeclaredProjectManage declaredProjectManage; | |||
private final DefaultDeclaredProjectManage defaultDeclaredProjectManage; | |||
private final NoticeManage noticeManage; | |||
/** | |||
* 部门联审 | |||
* @param project | |||
@@ -103,6 +103,10 @@ public class ReviewByDeptJointManage { | |||
return Boolean.FALSE; | |||
} | |||
//发送给第一个审批人消息 | |||
noticeManage.sendFirtUser(projectInfo,model.getFormName(),instanceId, | |||
WorkNoticeContant.PASS_MSG_TEMPLATE, MsgTypeEnum.PROJECT_REVIEW); | |||
return Boolean.TRUE; | |||
} | |||
@@ -299,6 +299,9 @@ public class ProjectDraft implements Serializable { | |||
@ApiModelProperty("用户id") | |||
private String userId; | |||
@ApiModelProperty("项目申报书") | |||
private String projectApplicationForm; | |||
private Long createBy; | |||
private Long updateBy; | |||
} |
@@ -303,6 +303,8 @@ public class ProjectDraftVO implements Serializable { | |||
@ApiModelProperty("21位项目编号") | |||
private String projectCode; | |||
@ApiModelProperty("项目申报书") | |||
private String projectApplicationForm; | |||
private Long createBy; | |||
private Long updateBy; | |||
@@ -4,14 +4,9 @@ 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; | |||
import com.ningdatech.basic.model.GenericResult; | |||
import com.ningdatech.pmapi.staging.model.entity.WorkNoticeStaging; | |||
import com.ningdatech.pmapi.staging.service.INdWorkNoticeStagingService; | |||
import com.ningdatech.pmapi.staging.utils.WorkNoticeFlowMapUtil; | |||
import com.ningdatech.pmapi.todocenter.bean.entity.WorkNoticeInfo; | |||
import com.ningdatech.zwdd.client.ZwddClient; | |||
import org.springframework.beans.BeanUtils; | |||
@@ -20,13 +15,8 @@ import org.springframework.stereotype.Component; | |||
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.service.IProjectStagingService; | |||
import com.ningdatech.pmapi.staging.utils.ProjectStatusFlowMapUtil; | |||
import cn.hutool.core.collection.CollUtil; | |||
import lombok.RequiredArgsConstructor; | |||
@@ -6,7 +6,7 @@ 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.service.IProjectStagingService; | |||
import com.ningdatech.pmapi.staging.utils.ProjectStatusFlowMapUtil; | |||
import com.ningdatech.pmapi.staging.utils.ProjectStatusFlowUtil; | |||
import lombok.RequiredArgsConstructor; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.stereotype.Service; | |||
@@ -28,7 +28,7 @@ public class ProjectStagingServiceImpl extends ServiceImpl<ProjectStagingMapper, | |||
private final ProjectStagingMapper mapper; | |||
private final ProjectStatusFlowMapUtil projectStatusFlowMapUtil; | |||
private final ProjectStatusFlowUtil projectStatusFlowUtil; | |||
/** | |||
* 在某些状态节点 增加一个项目到状态暂存库 | |||
@@ -61,11 +61,11 @@ public class ProjectStagingServiceImpl extends ServiceImpl<ProjectStagingMapper, | |||
@Override | |||
public Boolean addRetryTimes(ProjectStaging projectStaging) { | |||
Integer retryTimes = projectStaging.getRetryTimes() + 1; | |||
if(!projectStatusFlowMapUtil.intervalTimeMap.containsKey(retryTimes)){ | |||
if(!projectStatusFlowUtil.intervalTimeMap.containsKey(retryTimes)){ | |||
log.info("没有对应重试间隔时间 添加重试信息失败"); | |||
return Boolean.FALSE; | |||
} | |||
Integer addSeconds = projectStatusFlowMapUtil.intervalTimeMap.get(retryTimes); | |||
Integer addSeconds = projectStatusFlowUtil.intervalTimeMap.get(retryTimes); | |||
Boolean dead = Boolean.FALSE; | |||
//超过重试最大次数 dead置为 true | |||
if(retryTimes.compareTo(StagingContant.Retry.MAX_RETRY_TIMES) > 0){ | |||
@@ -29,10 +29,6 @@ public class ProjectStatusFlowMapUtil { | |||
private ReviewByDeptJointManage reviewByDeptJointManage; | |||
public Map<Integer, Function<Project,Boolean>> statusFlowFunctionMap = Maps.newHashMap(); | |||
/** | |||
* key 重试的次数 , value 是增加是描述 | |||
*/ | |||
public Map<Integer, Integer> intervalTimeMap = Maps.newHashMap(); | |||
/** | |||
* 初始化业务分派逻辑,代替了if-else部分 | |||
@@ -47,22 +43,4 @@ public class ProjectStatusFlowMapUtil { | |||
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); | |||
} | |||
} |
@@ -0,0 +1,45 @@ | |||
package com.ningdatech.pmapi.staging.utils; | |||
import com.google.common.collect.Maps; | |||
import com.ningdatech.pmapi.projectdeclared.manage.ReviewByDeptJointManage; | |||
import com.ningdatech.pmapi.projectdeclared.manage.ReviewByProvincialDeptManage; | |||
import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum; | |||
import com.ningdatech.pmapi.projectlib.model.entity.Project; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
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 | |||
public class ProjectStatusFlowUtil { | |||
/** | |||
* key 重试的次数 , value 是增加是描述 | |||
*/ | |||
public Map<Integer, Integer> intervalTimeMap = Maps.newHashMap(); | |||
/** | |||
* 初始化业务分派逻辑,代替了if-else部分 | |||
* key: 枚举 状态值 | |||
* value: lambda表达式,最终会获取发起实例的函数 | |||
*/ | |||
public ProjectStatusFlowUtil(){ | |||
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); | |||
} | |||
} |
@@ -2,6 +2,8 @@ package com.ningdatech.pmapi.staging.utils; | |||
import java.util.Map; | |||
import javax.annotation.PostConstruct; | |||
import lombok.AllArgsConstructor; | |||
import org.springframework.stereotype.Component; | |||
import com.google.common.collect.Maps; | |||
import lombok.RequiredArgsConstructor; | |||
@@ -13,7 +15,7 @@ import lombok.RequiredArgsConstructor; | |||
* @since 2023/02/28 17:03 | |||
*/ | |||
@Component | |||
@RequiredArgsConstructor | |||
@AllArgsConstructor | |||
public class WorkNoticeFlowMapUtil { | |||
/** | |||
* key 重试的次数 , value 是增加是描述 | |||
@@ -23,8 +25,7 @@ public class WorkNoticeFlowMapUtil { | |||
/** | |||
* 扫描的间隔越来越长 秒数 | |||
*/ | |||
@PostConstruct | |||
public void intervalTimeMapInit(){ | |||
public WorkNoticeFlowMapUtil(){ | |||
intervalTimeMap.put(1,60 * 2); | |||
intervalTimeMap.put(2,60 * 6); | |||
intervalTimeMap.put(3,60 * 15); | |||
@@ -2,32 +2,56 @@ package com.ningdatech.pmapi.sys.manage; | |||
import cn.hutool.core.bean.BeanUtil; | |||
import cn.hutool.core.util.StrUtil; | |||
import com.alibaba.fastjson.JSON; | |||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||
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.model.IdVo; | |||
import com.ningdatech.basic.model.PageVo; | |||
import com.ningdatech.basic.util.CollUtils; | |||
import com.ningdatech.file.entity.vo.result.AttachFileVo; | |||
import com.ningdatech.file.service.FileService; | |||
import com.ningdatech.pmapi.common.helper.UserInfoHelper; | |||
import com.ningdatech.pmapi.common.util.BizUtils; | |||
import com.ningdatech.pmapi.organization.model.entity.DingEmployeeInfo; | |||
import com.ningdatech.pmapi.organization.model.entity.DingOrganization; | |||
import com.ningdatech.pmapi.organization.service.IDingEmployeeInfoService; | |||
import com.ningdatech.pmapi.organization.service.IDingOrganizationService; | |||
import com.ningdatech.pmapi.projectlib.model.entity.Project; | |||
import com.ningdatech.pmapi.staging.enums.MsgTypeEnum; | |||
import com.ningdatech.pmapi.staging.service.INdWorkNoticeStagingService; | |||
import com.ningdatech.pmapi.sys.enumeration.NoticeTypeEnum; | |||
import com.ningdatech.pmapi.sys.model.entity.Notice; | |||
import com.ningdatech.pmapi.sys.model.entity.Notify; | |||
import com.ningdatech.pmapi.sys.model.req.NoticeListReq; | |||
import com.ningdatech.pmapi.sys.model.req.NoticeSaveReq; | |||
import com.ningdatech.pmapi.sys.model.req.NoticeStatusModifyReq; | |||
import com.ningdatech.pmapi.sys.model.vo.NoticeDetailVO; | |||
import com.ningdatech.pmapi.sys.model.vo.NoticeListItemVO; | |||
import com.ningdatech.pmapi.sys.service.INoticeService; | |||
import com.ningdatech.pmapi.sys.service.INotifyService; | |||
import com.ningdatech.pmapi.todocenter.bean.entity.WorkNoticeInfo; | |||
import com.ningdatech.pmapi.todocenter.model.dto.ProjectAuditMsgExtraDTO; | |||
import com.ningdatech.pmapi.user.entity.UserInfo; | |||
import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO; | |||
import com.ningdatech.pmapi.user.service.IUserInfoService; | |||
import lombok.RequiredArgsConstructor; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.apache.commons.lang3.StringUtils; | |||
import org.flowable.engine.RuntimeService; | |||
import org.flowable.engine.runtime.ActivityInstance; | |||
import org.springframework.stereotype.Component; | |||
import org.springframework.transaction.annotation.Transactional; | |||
import java.time.LocalDateTime; | |||
import java.util.List; | |||
import java.util.Map; | |||
import java.util.Objects; | |||
import java.util.stream.Collectors; | |||
import static com.ningdatech.pmapi.todocenter.constant.WorkNoticeContant.AUDIT_WORK_TITLE; | |||
/** | |||
* <p> | |||
* MsgManage | |||
@@ -38,11 +62,26 @@ import java.util.stream.Collectors; | |||
*/ | |||
@Component | |||
@RequiredArgsConstructor | |||
@Slf4j | |||
public class NoticeManage { | |||
private final INoticeService noticeService; | |||
private final FileService fileService; | |||
private final IUserInfoService userInfoService; | |||
private final IDingEmployeeInfoService dingEmployeeInfoService; | |||
private final IDingOrganizationService dingOrganizationService; | |||
private final INotifyService notifyService; | |||
private final INdWorkNoticeStagingService workNoticeStagingService; | |||
private final RuntimeService runtimeService; | |||
private final UserInfoHelper userInfoHelper; | |||
@Transactional(rollbackFor = Exception.class) | |||
public IdVo<Long> saveOrModify(NoticeSaveReq req) { | |||
Notice notice = BeanUtil.copyProperties(req, Notice.class); | |||
@@ -128,4 +167,117 @@ public class NoticeManage { | |||
noticeService.removeById(id); | |||
} | |||
/** | |||
* 发送消息 | |||
* @param employeeCode 员工号 | |||
* @param userId 用户ID | |||
* @param project 项目 | |||
* @param procDefinitionName 流程定义名 | |||
* @param template 消息模板内容 | |||
* @param msgTypeEnum 枚举 | |||
*/ | |||
public void sendNotice(String employeeCode, Long userId, Project project, String procDefinitionName, | |||
String template, MsgTypeEnum msgTypeEnum){ | |||
// 获取发送浙政钉工作通知必要信息 | |||
WorkNoticeInfo passWorkNoticeInfo = getSendWorkNoticeInfo(employeeCode); | |||
String passMsg = String.format(template, project.getProjectName(), procDefinitionName); | |||
passWorkNoticeInfo.setMsg(passMsg); | |||
// 放入系统通知表中,保存记录 | |||
Notify notify = assemblyAuditNotify(userId, project, passMsg); | |||
notify.setType(msgTypeEnum.name()); | |||
notifyService.save(notify); | |||
// 放入工作通知暂存表中,通过扫表异步发送 | |||
workNoticeStagingService.addByWorkNotice(passWorkNoticeInfo, msgTypeEnum); | |||
} | |||
/** | |||
* 获取发送浙政钉工作通知的信息 | |||
* | |||
* @param currentEmployeeCode | |||
* @return com.ningdatech.pmapi.todocenter.bean.entity.WorkNoticeInfo | |||
* @author CMM | |||
* @since 2023/02/15 14:04 | |||
*/ | |||
public WorkNoticeInfo getSendWorkNoticeInfo(String currentEmployeeCode) { | |||
UserInfo auditUserInfo = userInfoService.getOne(Wrappers.lambdaQuery(UserInfo.class).eq(UserInfo::getEmployeeCode,currentEmployeeCode).last("limit 1")); | |||
if (Objects.isNull(auditUserInfo)) { | |||
throw new BizException("该用户不存在!"); | |||
} | |||
WorkNoticeInfo workNoticeInfo = new WorkNoticeInfo(); | |||
Long accountId = auditUserInfo.getAccountId(); | |||
if (Objects.isNull(accountId)) { | |||
throw new BizException("该用户没有录入浙政钉信息!"); | |||
} | |||
workNoticeInfo.setAccountId(accountId); | |||
// 根据浙政钉用户ID获取部门code | |||
DingEmployeeInfo employeeInfo = dingEmployeeInfoService.getOne(Wrappers.lambdaQuery(DingEmployeeInfo.class) | |||
.eq(DingEmployeeInfo::getAccountId, accountId) | |||
.eq(DingEmployeeInfo::getMainJob,String.valueOf(Boolean.TRUE)) | |||
.last("limit 1")); | |||
String organizationCode = employeeInfo.getOrganizationCode(); | |||
workNoticeInfo.setOrganizationCode(organizationCode); | |||
// 根据部门code获取部门名称 | |||
DingOrganization dingOrganization = dingOrganizationService.getOne(Wrappers.lambdaQuery(DingOrganization.class) | |||
.eq(DingOrganization::getOrganizationCode, organizationCode)); | |||
String organizationName = dingOrganization.getOrganizationName(); | |||
workNoticeInfo.setOrganizationName(organizationName); | |||
// 构建唯一的消息ID | |||
String bizMsgId = "ZD_WORK_NOTICE_" + StrUtil.UNDERLINE + organizationCode + StrUtil.UNDERLINE | |||
+ organizationName + accountId + StrUtil.UNDERLINE + System.currentTimeMillis(); | |||
workNoticeInfo.setBizMsgId(bizMsgId); | |||
String receiverUserId = String.valueOf(accountId); | |||
workNoticeInfo.setReceiverUserId(receiverUserId); | |||
return workNoticeInfo; | |||
} | |||
/** | |||
* 装配项目审核工作通知 | |||
* @param userId | |||
* @param project | |||
* @param msg | |||
*/ | |||
private Notify assemblyAuditNotify(Long userId, Project project, String msg) { | |||
Notify notify = new Notify(); | |||
notify.setTitle(AUDIT_WORK_TITLE); | |||
notify.setUserId(userId); | |||
notify.setContent(msg); | |||
notify.setReaded(Boolean.FALSE); | |||
notify.setCreateTime(LocalDateTime.now()); | |||
ProjectAuditMsgExtraDTO msgExtraDto = new ProjectAuditMsgExtraDTO(); | |||
msgExtraDto.setProjectId(project.getId()); | |||
msgExtraDto.setInstanceId(project.getInstCode()); | |||
String extraJson = JSON.toJSONString(msgExtraDto); | |||
notify.setExtraInfo(extraJson); | |||
return notify; | |||
} | |||
/** | |||
* 找寻第一个审核人 去发消息 | |||
* @param project | |||
* @param formName | |||
* @param template | |||
* @param msgTypeEnum | |||
*/ | |||
public void sendFirtUser(Project project, String formName,String instanceId, String template, MsgTypeEnum msgTypeEnum) { | |||
try { | |||
List<ActivityInstance> activityInstances = runtimeService.createActivityInstanceQuery() | |||
.processInstanceId(instanceId) | |||
.activityType("userTask") | |||
.orderByActivityInstanceStartTime() | |||
.asc() | |||
.list(); | |||
for (ActivityInstance activityInstance : activityInstances) { | |||
if(StringUtils.isNotBlank(activityInstance.getAssignee())){ | |||
UserFullInfoDTO user = userInfoHelper.getUserFullInfoByEmployeeCode(activityInstance.getAssignee()); | |||
sendNotice(activityInstance.getAssignee(), user.getUserId(), project, formName, | |||
template, msgTypeEnum); | |||
} | |||
} | |||
}catch (Exception e){ | |||
log.error("发送消息失败 :" + e); | |||
} | |||
} | |||
} |
@@ -1,22 +1,13 @@ | |||
package com.ningdatech.pmapi.todocenter.manage; | |||
import cn.hutool.core.collection.CollUtil; | |||
import cn.hutool.core.util.StrUtil; | |||
import com.alibaba.fastjson.JSON; | |||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||
import com.ningdatech.basic.exception.BizException; | |||
import com.ningdatech.file.service.FileService; | |||
import com.ningdatech.pmapi.common.helper.UserInfoHelper; | |||
import com.ningdatech.pmapi.common.statemachine.util.StateMachineUtils; | |||
import com.ningdatech.pmapi.organization.model.entity.DingEmployeeInfo; | |||
import com.ningdatech.pmapi.organization.model.entity.DingOrganization; | |||
import com.ningdatech.pmapi.organization.service.IDingEmployeeInfoService; | |||
import com.ningdatech.pmapi.organization.service.IDingOrganizationService; | |||
import com.ningdatech.pmapi.projectdeclared.manage.DeclaredProjectManage; | |||
import com.ningdatech.pmapi.projectdeclared.manage.DefaultDeclaredProjectManage; | |||
import com.ningdatech.pmapi.projectdeclared.model.dto.ProjectDraftSaveDTO; | |||
import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum; | |||
import com.ningdatech.pmapi.projectlib.manage.ProjectLibManage; | |||
import com.ningdatech.pmapi.projectlib.model.dto.ProjectApplicationDTO; | |||
import com.ningdatech.pmapi.projectlib.model.dto.ProjectDTO; | |||
import com.ningdatech.pmapi.projectlib.model.entity.Project; | |||
@@ -25,29 +16,18 @@ import com.ningdatech.pmapi.projectlib.model.entity.ProjectInst; | |||
import com.ningdatech.pmapi.projectlib.service.IProjectApplicationService; | |||
import com.ningdatech.pmapi.projectlib.service.IProjectInstService; | |||
import com.ningdatech.pmapi.projectlib.service.IProjectService; | |||
import com.ningdatech.pmapi.signature.service.ICompanySignatureService; | |||
import com.ningdatech.pmapi.staging.enums.MsgTypeEnum; | |||
import com.ningdatech.pmapi.staging.service.INdWorkNoticeStagingService; | |||
import com.ningdatech.pmapi.staging.service.IProjectStagingService; | |||
import com.ningdatech.pmapi.sys.model.entity.Notify; | |||
import com.ningdatech.pmapi.sys.service.INotifyService; | |||
import com.ningdatech.pmapi.todocenter.bean.entity.WorkNoticeInfo; | |||
import com.ningdatech.pmapi.sys.manage.NoticeManage; | |||
import com.ningdatech.pmapi.todocenter.constant.TodoCenterContant; | |||
import com.ningdatech.pmapi.todocenter.model.dto.ProjectAuditMsgExtraDTO; | |||
import com.ningdatech.pmapi.todocenter.service.StatisticsService; | |||
import com.ningdatech.pmapi.todocenter.utils.BuildUserUtils; | |||
import com.ningdatech.pmapi.todocenter.utils.PdfUtils; | |||
import com.ningdatech.pmapi.user.entity.UserInfo; | |||
import com.ningdatech.pmapi.user.service.IUserInfoService; | |||
import com.ningdatech.pmapi.user.util.LoginUserUtil; | |||
import com.wflow.contants.HisProInsEndActId; | |||
import com.wflow.contants.WflowContant; | |||
import com.wflow.workflow.bean.process.ProgressNode; | |||
import com.wflow.workflow.bean.process.enums.NodeTypeEnum; | |||
import com.wflow.workflow.bean.vo.ProcessProgressVo; | |||
import com.wflow.workflow.enums.ProcessHandlerEnum; | |||
import com.wflow.workflow.service.ProcessInstanceService; | |||
import com.wflow.workflow.service.ProcessTaskService; | |||
import lombok.RequiredArgsConstructor; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.apache.commons.lang3.StringUtils; | |||
@@ -85,14 +65,11 @@ public class HandlerManage { | |||
private final IUserInfoService userInfoService; | |||
private final IProjectService projectService; | |||
private final StateMachineUtils stateMachineUtils; | |||
private final IDingEmployeeInfoService dingEmployeeInfoService; | |||
private final IDingOrganizationService dingOrganizationService; | |||
private final ProcessInstanceService processInstanceService; | |||
private final INdWorkNoticeStagingService workNoticeStagingService; | |||
private final IProjectApplicationService projectApplicationService; | |||
private final IProjectStagingService projectStagingService; | |||
private final IProjectInstService projectInstService; | |||
private final INotifyService notifyService; | |||
private final NoticeManage noticeManage; | |||
private final DeclaredProjectManage declaredProjectManage; | |||
/** | |||
@@ -147,16 +124,9 @@ public class HandlerManage { | |||
default: | |||
throw new IllegalStateException("Unexpected value: " + declaredProject.getStatus()); | |||
} | |||
// 获取发送浙政钉工作通知必要信息 | |||
WorkNoticeInfo passWorkNoticeInfo2 = getSendWorkNoticeInfo(currentEmployeeCode); | |||
String passMsg2 = String.format(PASS_MSG_TEMPLATE2, declaredProject.getProjectName(), instance.getProcessDefinitionName()); | |||
passWorkNoticeInfo2.setMsg(passMsg2); | |||
// 放入系统通知表中,保存记录 | |||
Notify notify = assemblyAuditNotify(userId, declaredProject, passMsg2); | |||
notify.setType(MsgTypeEnum.PROJECT_REVIEW_PASS.name()); | |||
notifyService.save(notify); | |||
// 放入工作通知暂存表中,通过扫表异步发送 | |||
workNoticeStagingService.addByWorkNotice(passWorkNoticeInfo2, MsgTypeEnum.PROJECT_REVIEW_PASS); | |||
//发送消息 | |||
noticeManage.sendNotice(currentEmployeeCode,userId,declaredProject,instance.getProcessDefinitionName(), | |||
PASS_MSG_TEMPLATE2,MsgTypeEnum.PROJECT_REVIEW_PASS); | |||
} else { | |||
// 若有下一个审核人(当前节点的用户), | |||
// 向其发送浙政钉工作通知:标题:审核任务 内容:【单位名称】的【项目名称】需要您审核。 | |||
@@ -164,18 +134,13 @@ public class HandlerManage { | |||
if (Objects.isNull(currentEmployeeCode)) { | |||
throw new BizException("审核人信息不存在!"); | |||
} | |||
WorkNoticeInfo sendWorkNoticeInfo = getSendWorkNoticeInfo(currentEmployeeCode); | |||
String msg = String.format(PASS_MSG_TEMPLATE, sendWorkNoticeInfo.getOrganizationName(), declaredProject.getProjectName()); | |||
sendWorkNoticeInfo.setMsg(msg); | |||
// 放入系统通知表中,保存记录 | |||
Notify notify = assemblyAuditNotify(userId, declaredProject, msg); | |||
notify.setType(MsgTypeEnum.PROJECT_REVIEW.name()); | |||
notifyService.save(notify); | |||
// 放入工作通知暂存表中,通过扫表异步发送 | |||
workNoticeStagingService.addByWorkNotice(sendWorkNoticeInfo, MsgTypeEnum.PROJECT_REVIEW); | |||
//发送消息 | |||
noticeManage.sendNotice(currentEmployeeCode,userId,declaredProject,instance.getProcessDefinitionName(), | |||
PASS_MSG_TEMPLATE,MsgTypeEnum.PROJECT_REVIEW); | |||
} | |||
} | |||
/** | |||
* 驳回后 所处理的逻辑 | |||
* @param declaredProject | |||
@@ -185,17 +150,9 @@ public class HandlerManage { | |||
Long userId = LoginUserUtil.getUserId(); | |||
// 更新项目状态和流程状态 | |||
updateRejectProjectStatus(userId, declaredProject); | |||
// 获取发送浙政钉工作通知必要信息 | |||
WorkNoticeInfo rejectWorkNoticeInfo = getSendWorkNoticeInfo(instance.getStartUserId()); | |||
String rejectMsg = String.format(REJECT_MSG_TEMPLATE, declaredProject.getProjectName(), | |||
instance.getProcessDefinitionName()); | |||
rejectWorkNoticeInfo.setMsg(rejectMsg); | |||
// 放入系统通知表中,保存记录 | |||
Notify notify = assemblyAuditNotify(userId, declaredProject, rejectMsg); | |||
notify.setType(MsgTypeEnum.PROJECT_REVIEW_REJECT.name()); | |||
notifyService.save(notify); | |||
// 放入工作通知暂存表中,通过扫表异步发送 | |||
workNoticeStagingService.addByWorkNotice(rejectWorkNoticeInfo, MsgTypeEnum.PROJECT_REVIEW_REJECT); | |||
//发送消息 | |||
noticeManage.sendNotice(instance.getStartUserId(),userId,declaredProject,instance.getProcessDefinitionName(), | |||
REJECT_MSG_TEMPLATE,MsgTypeEnum.PROJECT_REVIEW_REJECT); | |||
} | |||
/** | |||
@@ -269,17 +226,9 @@ public class HandlerManage { | |||
public void afterBackTodo(Project declaredProject, HistoricProcessInstance instance) { | |||
Long userId = LoginUserUtil.getUserId(); | |||
// 给项目创建人、流程发起人发送浙政钉工作通知:【项目名称】的【流程名称】被退回,请及时处理。 | |||
// 获取发送浙政钉工作通知必要信息 | |||
WorkNoticeInfo backWorkNoticeInfo = getSendWorkNoticeInfo(instance.getStartUserId()); | |||
String backMsg = String.format(BACK_MSG_TEMPLATE, declaredProject.getProjectName(), | |||
instance.getProcessDefinitionName()); | |||
backWorkNoticeInfo.setMsg(backMsg); | |||
// 放入系统通知表中,保存记录 | |||
Notify notify = assemblyAuditNotify(userId, declaredProject, backMsg); | |||
notify.setType(MsgTypeEnum.PROJECT_REVIEW_BACK.name()); | |||
notifyService.save(notify); | |||
// 放入工作通知暂存表中,通过扫表异步发送 | |||
workNoticeStagingService.addByWorkNotice(backWorkNoticeInfo, MsgTypeEnum.PROJECT_REVIEW_BACK); | |||
//发送消息 | |||
noticeManage.sendNotice(instance.getStartUserId(),userId,declaredProject,instance.getProcessDefinitionName(), | |||
BACK_MSG_TEMPLATE,MsgTypeEnum.PROJECT_REVIEW_BACK); | |||
} | |||
@@ -345,67 +294,6 @@ public class HandlerManage { | |||
projectService.updateById(declaredProject); | |||
} | |||
/** | |||
* 装配项目审核工作通知 | |||
* @param userId | |||
* @param project | |||
* @param msg | |||
*/ | |||
private Notify assemblyAuditNotify(Long userId, Project project, String msg) { | |||
Notify notify = new Notify(); | |||
notify.setTitle(AUDIT_WORK_TITLE); | |||
notify.setUserId(userId); | |||
notify.setContent(msg); | |||
notify.setReaded(Boolean.FALSE); | |||
notify.setCreateTime(LocalDateTime.now()); | |||
ProjectAuditMsgExtraDTO msgExtraDto = new ProjectAuditMsgExtraDTO(); | |||
msgExtraDto.setProjectId(project.getId()); | |||
msgExtraDto.setInstanceId(project.getInstCode()); | |||
String extraJson = JSON.toJSONString(msgExtraDto); | |||
notify.setExtraInfo(extraJson); | |||
return notify; | |||
} | |||
/** | |||
* 获取发送浙政钉工作通知的信息 | |||
* | |||
* @param currentEmployeeCode | |||
* @return com.ningdatech.pmapi.todocenter.bean.entity.WorkNoticeInfo | |||
* @author CMM | |||
* @since 2023/02/15 14:04 | |||
*/ | |||
public WorkNoticeInfo getSendWorkNoticeInfo(String currentEmployeeCode) { | |||
UserInfo auditUserInfo = userInfoService.getOne(Wrappers.lambdaQuery(UserInfo.class).eq(UserInfo::getEmployeeCode,currentEmployeeCode).last("limit 1")); | |||
if (Objects.isNull(auditUserInfo)) { | |||
throw new BizException("该用户不存在!"); | |||
} | |||
WorkNoticeInfo workNoticeInfo = new WorkNoticeInfo(); | |||
Long accountId = auditUserInfo.getAccountId(); | |||
if (Objects.isNull(accountId)) { | |||
throw new BizException("该用户没有录入浙政钉信息!"); | |||
} | |||
workNoticeInfo.setAccountId(accountId); | |||
// 根据浙政钉用户ID获取部门code | |||
DingEmployeeInfo employeeInfo = dingEmployeeInfoService.getOne(Wrappers.lambdaQuery(DingEmployeeInfo.class) | |||
.eq(DingEmployeeInfo::getAccountId, accountId) | |||
.eq(DingEmployeeInfo::getMainJob,String.valueOf(Boolean.TRUE)) | |||
.last("limit 1")); | |||
String organizationCode = employeeInfo.getOrganizationCode(); | |||
workNoticeInfo.setOrganizationCode(organizationCode); | |||
// 根据部门code获取部门名称 | |||
DingOrganization dingOrganization = dingOrganizationService.getOne(Wrappers.lambdaQuery(DingOrganization.class) | |||
.eq(DingOrganization::getOrganizationCode, organizationCode)); | |||
String organizationName = dingOrganization.getOrganizationName(); | |||
workNoticeInfo.setOrganizationName(organizationName); | |||
// 构建唯一的消息ID | |||
String bizMsgId = "ZD_WORK_NOTICE_" + StrUtil.UNDERLINE + organizationCode + StrUtil.UNDERLINE | |||
+ organizationName + accountId + StrUtil.UNDERLINE + System.currentTimeMillis(); | |||
workNoticeInfo.setBizMsgId(bizMsgId); | |||
String receiverUserId = String.valueOf(accountId); | |||
workNoticeInfo.setReceiverUserId(receiverUserId); | |||
return workNoticeInfo; | |||
} | |||
public void deleteBackComments(List<HistoricVariableInstance> approves) { | |||
if(CollUtil.isNotEmpty(approves)){ | |||
for(HistoricVariableInstance approve : approves){ | |||
@@ -125,10 +125,6 @@ public class UserInfoManage { | |||
} | |||
private List<String> getCompliantOrgEmpCodeList(String orgName, String orgCode, Long regionId) { | |||
if (Objects.nonNull(regionId) && regionId == 331100L) { | |||
// 丽水默认查全部 | |||
regionId = null; | |||
} | |||
if (StringUtils.isBlank(orgName) && StringUtils.isBlank(orgCode) && Objects.isNull(regionId)) { | |||
return null; | |||
} | |||
@@ -420,6 +416,8 @@ public class UserInfoManage { | |||
resUserDetailVO.setOrgCode(userFullInfo.getOrganizationCode()); | |||
resUserDetailVO.setOrgName(userFullInfo.getOrganizationName()); | |||
resUserDetailVO.setRegionCode(userFullInfo.getRegionCode()); | |||
resUserDetailVO.setRegionName(regionCacheHelper.getRegionName(userFullInfo.getRegionCode() | |||
,RegionConst.RL_COUNTY)); | |||
resUserDetailVO.setEmpPosUnitCode(userFullInfo.getEmpPosUnitCode()); | |||
resUserDetailVO.setEmpPosUnitName(userFullInfo.getEmpPosUnitName()); | |||
} | |||
@@ -434,7 +432,7 @@ public class UserInfoManage { | |||
userInfo.setUserName(u.getRealName()); | |||
// 根据 单位code获取单位名称 | |||
UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(u.getId()); | |||
if(Objects.nonNull(userFullInfo)){ | |||
if (Objects.nonNull(userFullInfo)) { | |||
userInfo.setOrgCode(userFullInfo.getEmpPosUnitCode()); | |||
userInfo.setOrgName(userFullInfo.getEmpPosUnitName()); | |||
} | |||
@@ -443,12 +441,12 @@ public class UserInfoManage { | |||
} | |||
public Map<String, ProcessInstanceUserDto> getUserMapByEmployeeCode(Set<String> staterUsers) { | |||
if(CollUtil.isEmpty(staterUsers)){ | |||
if (CollUtil.isEmpty(staterUsers)) { | |||
return Collections.emptyMap(); | |||
} | |||
List<UserInfo> userInfos = iUserInfoService.list(Wrappers.lambdaQuery(UserInfo.class) | |||
.in(UserInfo::getEmployeeCode,staterUsers)); | |||
if(CollUtil.isEmpty(userInfos)){ | |||
.in(UserInfo::getEmployeeCode, staterUsers)); | |||
if (CollUtil.isEmpty(userInfos)) { | |||
return Collections.emptyMap(); | |||
} | |||
return userInfos.stream().map(u -> { | |||
@@ -457,7 +455,7 @@ public class UserInfoManage { | |||
userInfo.setUserName(u.getRealName()); | |||
// 根据 单位code获取单位名称 | |||
UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(u.getId()); | |||
if(Objects.nonNull(userFullInfo)){ | |||
if (Objects.nonNull(userFullInfo)) { | |||
userInfo.setOrgCode(userFullInfo.getEmpPosUnitCode()); | |||
userInfo.setOrgName(userFullInfo.getEmpPosUnitName()); | |||
} | |||
@@ -472,7 +470,7 @@ public class UserInfoManage { | |||
processInstanceUserDto.setUserName(userInfo.getRealName()); | |||
// 根据 单位code获取单位名称 | |||
UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(userInfo.getId()); | |||
if(Objects.nonNull(userFullInfo)){ | |||
if (Objects.nonNull(userFullInfo)) { | |||
processInstanceUserDto.setOrgCode(userFullInfo.getEmpPosUnitCode()); | |||
processInstanceUserDto.setOrgName(userFullInfo.getEmpPosUnitName()); | |||
} | |||
@@ -4,9 +4,11 @@ import com.ningdatech.pmapi.common.constant.RegionConst; | |||
import io.swagger.annotations.ApiModel; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.Data; | |||
import org.apache.commons.lang3.StringUtils; | |||
import java.time.LocalDateTime; | |||
import java.util.List; | |||
import java.util.Objects; | |||
/** | |||
* @author liuxinxin | |||
@@ -40,6 +42,7 @@ public class ResUserDetailVO { | |||
@ApiModelProperty("所属区域") | |||
private Long regionId; | |||
private String regionCode; | |||
private String regionName; | |||
@ApiModelProperty("用户任职所在单位code") | |||
private String empPosUnitCode; | |||
@@ -51,6 +51,7 @@ public class WorkbenchManage { | |||
public WorkbenchVO getWorkbenchData(Integer year){ | |||
WorkbenchVO res = new WorkbenchVO(); | |||
UserInfoDetails user = LoginUserUtil.loginUserDetail(); | |||
//1.待办中心数据 | |||
TodoCenterStatisticsVO statisticsVO = todoCenterManage.todoCenterStatistics(); | |||
@@ -70,6 +71,7 @@ public class WorkbenchManage { | |||
projectListReq.setPageNumber(1); | |||
projectListReq.setPageSize(5); | |||
projectListReq.setProjectYear(year); | |||
projectListReq.setBuildOrgCode(user.getEmpPosUnitCode()); | |||
res.setProjects(projectLibManage.projectLibListWithPermission(projectListReq).getRecords().stream().collect(Collectors.toList())); | |||
//3.所有公告按类型分 | |||
@@ -13,6 +13,7 @@ import com.ningdatech.pmapi.projectlib.model.entity.Project; | |||
import com.ningdatech.pmapi.projectlib.model.vo.ProjectDetailVO; | |||
import com.ningdatech.pmapi.projectlib.service.IProjectService; | |||
import com.ningdatech.pmapi.staging.service.INdWorkNoticeStagingService; | |||
import com.ningdatech.pmapi.sys.manage.NoticeManage; | |||
import com.ningdatech.pmapi.todocenter.bean.entity.WorkNoticeInfo; | |||
import com.ningdatech.pmapi.todocenter.manage.HandlerManage; | |||
import com.ningdatech.pmapi.todocenter.manage.TodoCenterManage; | |||
@@ -72,7 +73,7 @@ public class TodoCenterTest extends AppTests { | |||
private HistoryService historyService; | |||
@Autowired | |||
private HandlerManage handlerManage; | |||
private NoticeManage handlerManage; | |||
@Test | |||
public void sendWorkNoticeTest() throws ExecutionException, InterruptedException { | |||