@@ -58,6 +58,7 @@ import com.hz.pm.api.projectlib.helper.ProjectManageUtil; | |||
import com.hz.pm.api.projectlib.model.constant.ProjectConstant; | |||
import com.hz.pm.api.projectlib.model.dto.GovSystemReplaceInfoDTO; | |||
import com.hz.pm.api.projectlib.model.dto.ProjectDTO; | |||
import com.hz.pm.api.projectlib.model.dto.ProjectGovSystemReplaceInfosDTO; | |||
import com.hz.pm.api.projectlib.model.dto.ProjectPaymentPlanDTO; | |||
import com.hz.pm.api.projectlib.model.entity.*; | |||
import com.hz.pm.api.projectlib.model.enumeration.InstTypeEnum; | |||
@@ -234,7 +235,7 @@ public class ProjectLibManage { | |||
item.setProcessStatus(w.getProcessStatus()); | |||
item.setInstCode(w.getInstCode()); | |||
item.setIsHigherSuperOrg(w.getIsHigherSuperOrg()); | |||
if (user.getIsOrgAdmin() && StringUtils.isNotBlank(w.getSuperOrgCode()) | |||
if (user.isOrgAdmin() && StringUtils.isNotBlank(w.getSuperOrgCode()) | |||
&& w.getSuperOrgCode().equals(user.getMhUnitIdStr())) { | |||
item.setCanPreDeclared(Boolean.TRUE); | |||
} | |||
@@ -312,7 +313,7 @@ public class ProjectLibManage { | |||
item.setInstCode(w.getInstCode()); | |||
item.setIsHigherSuperOrg(w.getIsHigherSuperOrg()); | |||
item.setApproveUsers(buildApproveUsers(w.getInstCode(), map, userMap)); | |||
if (user.getIsOrgAdmin() && StringUtils.isNotBlank(w.getSuperOrgCode()) | |||
if (user.isOrgAdmin() && StringUtils.isNotBlank(w.getSuperOrgCode()) | |||
&& w.getSuperOrgCode().equals(user.getMhUnitIdStr())) { | |||
item.setCanPreDeclared(Boolean.TRUE); | |||
} | |||
@@ -414,7 +415,7 @@ public class ProjectLibManage { | |||
item.setProcessStatus(w.getProcessStatus()); | |||
item.setInstCode(w.getInstCode()); | |||
item.setIsHigherSuperOrg(w.getIsHigherSuperOrg()); | |||
if (user.getIsOrgAdmin() && StringUtils.isNotBlank(w.getSuperOrgCode()) | |||
if (user.isOrgAdmin() && StringUtils.isNotBlank(w.getSuperOrgCode()) | |||
&& w.getSuperOrgCode().equals(user.getMhUnitIdStr())) { | |||
item.setCanPreDeclared(Boolean.TRUE); | |||
} | |||
@@ -473,7 +474,7 @@ public class ProjectLibManage { | |||
item.setProcessStatus(w.getProcessStatus()); | |||
item.setInstCode(w.getInstCode()); | |||
item.setIsHigherSuperOrg(w.getIsHigherSuperOrg()); | |||
if (user.getIsOrgAdmin() && StringUtils.isNotBlank(w.getSuperOrgCode()) | |||
if (user.isOrgAdmin() && StringUtils.isNotBlank(w.getSuperOrgCode()) | |||
&& w.getSuperOrgCode().equals(user.getMhUnitIdStr())) { | |||
item.setCanPreDeclared(Boolean.TRUE); | |||
} | |||
@@ -565,7 +566,7 @@ public class ProjectLibManage { | |||
item.setInstCode(w.getInstCode()); | |||
item.setIsHigherSuperOrg(w.getIsHigherSuperOrg()); | |||
item.setApproveUsers(buildApproveUsers(w.getInstCode(), map, userMap)); | |||
if (user.getIsOrgAdmin() && StringUtils.isNotBlank(w.getSuperOrgCode()) | |||
if (user.isOrgAdmin() && StringUtils.isNotBlank(w.getSuperOrgCode()) | |||
&& w.getSuperOrgCode().equals(user.getMhUnitIdStr())) { | |||
item.setCanPreDeclared(Boolean.TRUE); | |||
} | |||
@@ -750,7 +751,8 @@ public class ProjectLibManage { | |||
if (tmpPersons != null) { | |||
purchaseFullInfo.setFirstInspectedPersons(convertPersons(tmpPersons)); | |||
} | |||
purchaseFullInfo.setSystemReplaceInfos(replaceInfosMap.get(k)); | |||
List<ProjectGovSystemReplaceInfosDTO> replaceInfos = BeanUtil.copyToList(replaceInfosMap.get(k), ProjectGovSystemReplaceInfosDTO.class); | |||
purchaseFullInfo.setSystemReplaceInfos(replaceInfos); | |||
retProjectDetail.getPurchaseDetails().add(purchaseFullInfo); | |||
}); | |||
// 建设方案 | |||
@@ -1,30 +1,23 @@ | |||
package com.hz.pm.api.scheduler.contants; | |||
import com.hz.pm.api.common.enumeration.ProjectProcessType; | |||
/** | |||
* @author PoffyZhang | |||
* @Classname TaskContant | |||
* @Description | |||
* @Date 2023/1/18 11:00 | |||
*/ | |||
public interface TaskConstant { | |||
class Wflow { | |||
public class TaskConstant { | |||
public static final Integer[] APPLY_PROCESS_TYPE_LIST = { | |||
ProjectProcessType.APPLY_DELAY.getCode(), | |||
ProjectProcessType.APPLY_BORROW.getCode() | |||
}; | |||
private TaskConstant() { | |||
// do nothing | |||
} | |||
class ProvinceReview { | |||
public static final String END_NODE_ID = "结束"; | |||
public static class StepName { | |||
public static final String END_STEP = "流程结束"; | |||
} | |||
private StepName() { | |||
// do nothing | |||
} | |||
class StepName { | |||
public static final String PURCHASE = "采购"; | |||
public static final String ADAPT_MODIFY = "适配改造"; | |||
public static final String FINAL = "终验"; | |||
@@ -1,32 +1,20 @@ | |||
package com.hz.pm.api.sys.manage; | |||
import cn.hutool.core.bean.BeanUtil; | |||
import cn.hutool.core.collection.CollUtil; | |||
import cn.hutool.core.date.StopWatch; | |||
import cn.hutool.core.util.IdUtil; | |||
import com.alibaba.fastjson.JSON; | |||
import com.ningdatech.basic.exception.BizException; | |||
import com.ningdatech.basic.util.CollUtils; | |||
import com.hz.pm.api.common.model.constant.BizConst; | |||
import com.hz.pm.api.common.model.constant.RegionConst; | |||
import com.hz.pm.api.common.enumeration.ProjectProcessType; | |||
import com.hz.pm.api.common.helper.RegionCacheHelper; | |||
import com.hz.pm.api.common.model.entity.MenuTreeEntity; | |||
import com.hz.pm.api.common.util.TreeUtil; | |||
import com.hz.pm.api.scheduler.contants.TaskConstant; | |||
import com.hz.pm.api.sys.model.dto.RegionDTO; | |||
import com.hz.pm.api.sys.model.entity.Menu; | |||
import com.hz.pm.api.sys.model.vo.MenuRoleVO; | |||
import com.hz.pm.api.sys.service.IMenuService; | |||
import com.wflow.bean.dto.WflowModelHistorysInsertDto; | |||
import com.wflow.workflow.bean.process.ProcessNode; | |||
import com.wflow.workflow.service.ProcessModelService; | |||
import com.ningdatech.basic.util.CollUtils; | |||
import lombok.RequiredArgsConstructor; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.apache.commons.lang3.StringUtils; | |||
import org.springframework.stereotype.Component; | |||
import java.util.*; | |||
import java.util.HashSet; | |||
import java.util.List; | |||
import java.util.Set; | |||
import java.util.stream.Collectors; | |||
/** | |||
@@ -43,8 +31,6 @@ import java.util.stream.Collectors; | |||
public class MenuManage { | |||
private final IMenuService menuService; | |||
private final ProcessModelService processModelService; | |||
private final RegionCacheHelper regionCacheHelper; | |||
public List<MenuRoleVO> buildUserMenu(List<Menu> list) { | |||
Set<Long> menuIds = new HashSet<>(); | |||
@@ -80,52 +66,4 @@ public class MenuManage { | |||
parentMenuCheck(tmpPidList, menuRoles, menuIds); | |||
} | |||
public String init() { | |||
log.info("=========== 初始化丽水二期 系统表单和流程配置 ======== 任务开始"); | |||
StopWatch stopWatch = new StopWatch(); | |||
stopWatch.start(); | |||
//1.查出丽水市下的 区县 分别去初始化 表单和流程配置数据 | |||
List<RegionDTO> regions = regionCacheHelper.listChildren(RegionConst.RC_HZ, RegionConst.RL_CITY); | |||
if(CollUtil.isEmpty(regions)){ | |||
throw new BizException("丽水地区数据为空 任务结束!"); | |||
} | |||
for(RegionDTO region : regions){ | |||
log.info("当前初始化的是 【{}】 流程配置",region.getRegionName()); | |||
Integer[] processTypeList = TaskConstant.Wflow.APPLY_PROCESS_TYPE_LIST; | |||
for(Integer processType : processTypeList){ | |||
String formName = ProjectProcessType.getDesc(processType); | |||
WflowModelHistorysInsertDto models = new WflowModelHistorysInsertDto(); | |||
models.setGroupId(1); | |||
models.setProcessDefId("pd" + IdUtil.objectId()); | |||
models.setFormName(formName); | |||
models.setProcessType(processType); | |||
models.setRegionCode(region.getRegionCode()); | |||
String process = "{\"children\":{\"children\":{},\"id\":\"node_039152532706\",\"name\":\"审批人\",\"parentId\":\"root\",\"props\":{\"mode\":\"AND\",\"role\":[],\"refuse\":{\"type\":\"TO_END\",\"target\":\"\"},\"assignedOrg\":[{\"orgName\":\"数转办\",\"orgCode\":\"GO_3bc86256687a4884ae410af00682b762\",\"type\":\"DEFAULT\",\"processDefId\":\"\"}],\"sign\":false,\"assignedType\":\"ASSIGN_ORG\",\"assignedDept\":[]},\"type\":\"SUB\"},\"id\":\"root\",\"name\":\"发起人\",\"props\":{\"formPerms\":[],\"assignedUser\":[]},\"type\":\"ROOT\"}"; | |||
ProcessNode processNode = JSON.parseObject(process,ProcessNode.class); | |||
models.setProcess(processNode); | |||
models.setSettings("{\"sign\":false,\"admin\":[],\"notify\":{},\"commiter\":[]}"); | |||
models.setFormItems("[]"); | |||
String formId = processModelService.insertProcess(models); | |||
if(StringUtils.isNotBlank(formId)){ | |||
//初始的流程在部署表也存一份,用来查询 | |||
if(StringUtils.isNotBlank(processModelService.deployProcess(formId,null))){ | |||
log.info("当前区域 【{}】 流程名[{}] 流程数据已经保存成功",region.getRegionName(),formName); | |||
}else{ | |||
log.info("当前区域 【{}】 流程名[{}] 流程数据保存失败",region.getRegionName(),formName); | |||
} | |||
}else{ | |||
log.info("当前区域 【{}】流程名[{}] 流程数据保存失败",region.getRegionName(),formName); | |||
} | |||
} | |||
} | |||
stopWatch.stop(); | |||
log.info("=========== 初始化丽水二期 系统表单和流程配置 ======== 任务结束 {}s",stopWatch.getTotalTimeSeconds()); | |||
return "初始化完成"; | |||
} | |||
} |
@@ -343,9 +343,9 @@ public class NoticeManage { | |||
private void permissionsWrapperByEdit(LambdaQueryWrapper<Notice> wrapper, UserFullInfoDTO user) { | |||
//如果是超管 就能看所有 | |||
if (user.getSuperAdmin() || user.getRegionAdmin()) { | |||
if (user.isSuperAdmin() || user.isRegionAdmin()) { | |||
log.info(user.getUsername() + ",超管可以看所有"); | |||
} else if (user.getIsOrgAdmin()) { | |||
} else if (user.isOrgAdmin()) { | |||
wrapper.eq(Notice::getPermissions, NoticePermissionsEnum.ORG.getCode()) | |||
.eq(Notice::getPermissionsValue, user.getMhUnitIdStr()); | |||
} else { | |||
@@ -2,15 +2,9 @@ package com.hz.pm.api.sys.utils; | |||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||
import com.hz.pm.api.projectlib.model.entity.Project; | |||
import com.hz.pm.api.sys.model.entity.ProjectEarlyWarning; | |||
import com.hz.pm.api.sys.model.entity.WflowEarlyWarningRecords; | |||
import com.hz.pm.api.user.helper.MhUnitCache; | |||
import com.hz.pm.api.user.security.model.UserFullInfoDTO; | |||
import com.hz.pm.api.user.security.model.UserInfoDetails; | |||
import lombok.AllArgsConstructor; | |||
import lombok.RequiredArgsConstructor; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Component; | |||
/** | |||
* @Classname EarlyWarningUtil | |||
@@ -39,9 +33,9 @@ public class EarlyWarningUtil { | |||
public static void buildPermissionFullWrapper(LambdaQueryWrapper<WflowEarlyWarningRecords> wrapper, | |||
UserFullInfoDTO user) { | |||
//如果是超管的话 | |||
if (user.getSuperAdmin() || user.getRegionAdmin()) { | |||
if (user.isSuperAdmin() || user.isRegionAdmin()) { | |||
// 可以看所有 | |||
} else if (user.getIsOrgAdmin()) { | |||
} else if (user.isOrgAdmin()) { | |||
wrapper.eq(WflowEarlyWarningRecords::getBuildOrgCode, user.getMhUnitIdStr()); | |||
} else { | |||
//否则都只能看自己单位的 | |||
@@ -52,9 +46,9 @@ public class EarlyWarningUtil { | |||
public static void buildPermissionProjectWrapper(LambdaQueryWrapper<Project> wrapper, | |||
UserFullInfoDTO user) { | |||
//如果是超管的话 | |||
if (user.getSuperAdmin()) { | |||
if (user.isSuperAdmin()) { | |||
// 看所有 | |||
} else if (user.getIsOrgAdmin()) { | |||
} else if (user.isOrgAdmin()) { | |||
wrapper.eq(Project::getBuildOrgCode, user.getMhUnitIdStr()); | |||
} else { | |||
//否则都只能看自己单位的 | |||
@@ -13,6 +13,6 @@ public class SessionTimeConst { | |||
public static final Integer SESSION_TIME_SECONDS = 24 * 60 * 60 * 10; | |||
public static final Integer SESSION_EXPIRED = 0; | |||
public static final String UNIVERSAL_VERIFICATION_CODE = "9527"; | |||
public static final String SUPER_VERIFY_CODE = "9527"; | |||
} |
@@ -10,6 +10,6 @@ public class UserDetailsServiceConstant { | |||
private UserDetailsServiceConstant() { | |||
} | |||
public static final String USER_DETAILS_SERVICE_SEPARATOR = "@###@"; | |||
public static final String SEPARATOR = "@###@"; | |||
} |
@@ -7,23 +7,25 @@ import com.hz.pm.api.user.security.auth.constants.SessionTimeConst; | |||
import com.hz.pm.api.user.security.auth.constants.UserDetailsServiceConstant; | |||
import com.hz.pm.api.user.security.exception.BizLoginException; | |||
import com.ningdatech.basic.exception.BizException; | |||
import lombok.Setter; | |||
import org.springframework.security.authentication.AuthenticationProvider; | |||
import org.springframework.security.authentication.BadCredentialsException; | |||
import org.springframework.security.core.Authentication; | |||
import org.springframework.security.core.AuthenticationException; | |||
import org.springframework.security.core.userdetails.UserDetails; | |||
import org.springframework.security.core.userdetails.UserDetailsService; | |||
import org.springframework.security.crypto.password.PasswordEncoder; | |||
/** | |||
* @Author LiuXinXin | |||
* @Date 2020/8/3 8:55 下午 | |||
* @Version 1.0 | |||
**/ | |||
* <p> | |||
* CredentialAuthProvider | |||
* </p> | |||
* | |||
* @author WendyYang | |||
* @since 09:26 2024/9/12 | |||
*/ | |||
@Setter | |||
public class CredentialAuthProvider implements AuthenticationProvider { | |||
private UserDetailsService userDetailsService; | |||
private PasswordEncoder passwordEncoder; | |||
private Boolean phoneVerifyCodeSkip; | |||
private VerifyCodeCheckHelper verifyCodeCheckHelper; | |||
@@ -37,61 +39,35 @@ public class CredentialAuthProvider implements AuthenticationProvider { | |||
CredentialAuthToken authenticationToken = (CredentialAuthToken) authentication; | |||
String principal = (String) authenticationToken.getPrincipal(); | |||
UserDetails user = null; | |||
LoginTypeEnum loginTypeEnum = authenticationToken.getLoginTypeEnum(); | |||
UserDetails user; | |||
LoginTypeEnum loginType = authenticationToken.getLoginTypeEnum(); | |||
String credentials = (String) authenticationToken.getCredentials(); | |||
switch (loginTypeEnum) { | |||
switch (loginType) { | |||
case PHONE_VERIFICATION_CODE_LOGIN: { | |||
if (Boolean.FALSE.equals(phoneVerifyCodeSkip)) { | |||
// 校验短信验证码 | |||
boolean verificationResult = verifyCodeCheckHelper.verification(VerificationCodeType.LOGIN, principal, credentials); | |||
if (!verificationResult && !SessionTimeConst.UNIVERSAL_VERIFICATION_CODE.equals(credentials)) { | |||
boolean valid = verifyCodeCheckHelper.verification(VerificationCodeType.LOGIN, principal, credentials); | |||
if (!valid && !SessionTimeConst.SUPER_VERIFY_CODE.equals(credentials)) { | |||
throw new BizLoginException("验证码错误"); | |||
} | |||
} | |||
user = userDetailsService.loadUserByUsername(principal + UserDetailsServiceConstant.USER_DETAILS_SERVICE_SEPARATOR + loginTypeEnum.name()); | |||
user = userDetailsService.loadUserByUsername(principal + UserDetailsServiceConstant.SEPARATOR + loginType.name()); | |||
} | |||
break; | |||
case USERNAME_PASSWORD_LOGIN: { | |||
user = userDetailsService.loadUserByUsername(principal + UserDetailsServiceConstant.USER_DETAILS_SERVICE_SEPARATOR + loginTypeEnum.name()); | |||
user = userDetailsService.loadUserByUsername(principal + UserDetailsServiceConstant.SEPARATOR + loginType.name()); | |||
} | |||
break; | |||
default: | |||
throw new BizException("不支持的登录方式"); | |||
} | |||
// 将用户定义的user放入token中,这样可以在session中查询到所有自定义的用户信息 | |||
return new CredentialAuthToken(user, user.getPassword(), user.getAuthorities()); | |||
} | |||
protected void additionalAuthenticationChecks(UserDetails userDetails, CredentialAuthToken authentication) | |||
throws AuthenticationException { | |||
if (authentication.getCredentials() == null) { | |||
throw new BadCredentialsException("login fail! password is null"); | |||
} | |||
String presentedPassword = authentication.getCredentials().toString(); | |||
if (!passwordEncoder.matches(presentedPassword, userDetails.getPassword())) { | |||
throw new BadCredentialsException("login fail! password is error"); | |||
} | |||
} | |||
@Override | |||
public boolean supports(Class<?> authentication) { | |||
return CredentialAuthToken.class.isAssignableFrom(authentication); | |||
} | |||
public void setUserDetailsService(UserDetailsService userDetailsService) { | |||
this.userDetailsService = userDetailsService; | |||
} | |||
public void setPasswordEncoder(PasswordEncoder passwordEncoder) { | |||
this.passwordEncoder = passwordEncoder; | |||
} | |||
public void setVerifyCodeCheckHelper(VerifyCodeCheckHelper verifyCodeCheckHelper) { | |||
this.verifyCodeCheckHelper = verifyCodeCheckHelper; | |||
} | |||
public void setPhoneVerifyCodeSkip(Boolean phoneVerifyCodeSkip) { | |||
this.phoneVerifyCodeSkip = phoneVerifyCodeSkip; | |||
} | |||
} |
@@ -39,8 +39,6 @@ public class CredentialAuthSecurityConfig extends SecurityConfigurerAdapter<Defa | |||
@Qualifier(value = "credentialLoginUserDetailService") | |||
private UserDetailsService credentialLoginUserDetailService; | |||
@Autowired | |||
private PasswordEncoder passwordEncoder; | |||
@Autowired | |||
private AuthProperties authProperties; | |||
@Autowired | |||
private VerifyCodeCheckHelper verifyCodeCheckHelper; | |||
@@ -54,16 +52,12 @@ public class CredentialAuthSecurityConfig extends SecurityConfigurerAdapter<Defa | |||
credentialAuthFilter.setAuthenticationSuccessHandler(defaultLoginSuccessHandler); | |||
credentialAuthFilter.setAuthenticationFailureHandler(defaultLoginFailureHandler); | |||
CredentialAuthProvider authenticationProvider = new CredentialAuthProvider(); | |||
authenticationProvider.setPhoneVerifyCodeSkip(skipLoginVerifyCodeCheck); | |||
authenticationProvider.setUserDetailsService(credentialLoginUserDetailService); | |||
// 确保对密码进行加密的encoder和解密的encoder相同 | |||
authenticationProvider.setPasswordEncoder(passwordEncoder); | |||
// 传入浙政钉client | |||
authenticationProvider.setVerifyCodeCheckHelper(verifyCodeCheckHelper); | |||
http.authenticationProvider(authenticationProvider).addFilterAfter(credentialAuthFilter, | |||
UsernamePasswordAuthenticationFilter.class); | |||
CredentialAuthProvider authProvider = new CredentialAuthProvider(); | |||
authProvider.setPhoneVerifyCodeSkip(skipLoginVerifyCodeCheck); | |||
authProvider.setUserDetailsService(credentialLoginUserDetailService); | |||
authProvider.setVerifyCodeCheckHelper(verifyCodeCheckHelper); | |||
http.authenticationProvider(authProvider) | |||
.addFilterAfter(credentialAuthFilter, UsernamePasswordAuthenticationFilter.class); | |||
} | |||
} |
@@ -29,7 +29,7 @@ public class CredentialLoginUserDetailService implements UserDetailsService { | |||
@Override | |||
public UserInfoDetails loadUserByUsername(String username) throws UsernameNotFoundException { | |||
String[] split = username.split(UserDetailsServiceConstant.USER_DETAILS_SERVICE_SEPARATOR); | |||
String[] split = username.split(UserDetailsServiceConstant.SEPARATOR); | |||
username = split[0]; | |||
String loginTypeStr = split[1]; | |||
LoginTypeEnum loginTypeEnum = LoginTypeEnum.valueOf(loginTypeStr); | |||
@@ -11,7 +11,12 @@ import javax.servlet.http.HttpServletResponse; | |||
import java.io.IOException; | |||
/** | |||
* 默认的退出成功处理器 | |||
* <p> | |||
* DefaultLogoutSuccessHandler | |||
* </p> | |||
* | |||
* @author WendyYang | |||
* @since 09:35 2024/9/12 | |||
*/ | |||
@Component("defaultLogoutSuccessHandler") | |||
public class DefaultLogoutSuccessHandler implements LogoutSuccessHandler { | |||
@@ -2,8 +2,8 @@ package com.hz.pm.api.user.security.model; | |||
import cn.hutool.core.collection.CollUtil; | |||
import com.hz.pm.api.sys.model.entity.Role; | |||
import com.hz.pm.api.user.model.enumeration.UserAvailableEnum; | |||
import com.hz.pm.api.user.model.enumeration.RoleEnum; | |||
import com.hz.pm.api.user.model.enumeration.UserAvailableEnum; | |||
import lombok.Data; | |||
import java.util.List; | |||
@@ -88,22 +88,18 @@ public class UserFullInfoDTO { | |||
return null; | |||
} | |||
public boolean getIsOrgAdmin() { | |||
public boolean isOrgAdmin() { | |||
return containsRole(RoleEnum.COMPANY_MANAGER); | |||
} | |||
public boolean getSuperAdmin() { | |||
public boolean isSuperAdmin() { | |||
return containsRole(RoleEnum.SUPER_ADMIN); | |||
} | |||
public boolean getRegionAdmin() { | |||
public boolean isRegionAdmin() { | |||
return containsRole(RoleEnum.REGION_MANAGER); | |||
} | |||
public Boolean notAdmin() { | |||
return !getSuperAdmin() && !getRegionAdmin() && !getIsOrgAdmin(); | |||
} | |||
public String getMhUnitIdStr() { | |||
return String.valueOf(getMhUnitId()); | |||
} | |||
@@ -1,156 +0,0 @@ | |||
package com.hz.pm.api.sys.processDef; | |||
import cn.hutool.core.collection.CollUtil; | |||
import cn.hutool.core.date.StopWatch; | |||
import cn.hutool.core.util.IdUtil; | |||
import com.alibaba.fastjson.JSON; | |||
import com.ningdatech.basic.exception.BizException; | |||
import com.hz.pm.api.AppTests; | |||
import com.hz.pm.api.common.model.constant.RegionConst; | |||
import com.hz.pm.api.common.enumeration.ProjectProcessType; | |||
import com.hz.pm.api.common.helper.RegionCacheHelper; | |||
import com.hz.pm.api.scheduler.contants.TaskConstant; | |||
import com.hz.pm.api.sys.model.dto.RegionDTO; | |||
import com.wflow.bean.dto.WflowModelHistorysInsertDto; | |||
import com.wflow.workflow.bean.process.ProcessNode; | |||
import com.wflow.workflow.service.ProcessModelService; | |||
import com.wflow.workflow.service.WflowFormsService; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.apache.commons.lang3.StringUtils; | |||
import org.junit.Test; | |||
import javax.annotation.Resource; | |||
import java.time.LocalDateTime; | |||
import java.time.format.DateTimeFormatter; | |||
import java.util.List; | |||
/** | |||
* @Classname ProcessTest | |||
* @Description | |||
* @Date 2023/2/4 9:54 | |||
* @Author PoffyZhang | |||
*/ | |||
@Slf4j | |||
public class ProcessDefTest extends AppTests { | |||
@Resource | |||
private ProcessModelService processModelService; | |||
@Resource | |||
private WflowFormsService formsService; | |||
@Resource | |||
private RegionCacheHelper regionCacheHelper; | |||
@Test | |||
public void test() { | |||
String processStr = "{\"id\":\"node_039152532706\",\"name\":\"审批单位\",\"type\":\"ORG\",\"props\":{\"regionCode\":\"\",\"orgCode\":\"GO_3bc86256687a4884ae410af00682b762\",\"type\":\"DEFAULT\",\"processDefId\":\"\",\"subNode\":[]},\"children\":{},\"parentId\":\"root\"}"; | |||
Node node = JSON.parseObject(processStr, Node.class); | |||
OrgProps props = JSON.parseObject(node.getProps().toString(), OrgProps.class); | |||
System.out.println(props.getOrgCode()); | |||
} | |||
@Test | |||
public void date(){ | |||
System.out.println(LocalDateTime.parse("2023-02-05 10:25", DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"))); | |||
} | |||
@Test | |||
public void apply() { | |||
log.info("=========== 初始化丽水二期 系统表单和流程配置 ======== 任务开始"); | |||
StopWatch stopWatch = new StopWatch(); | |||
stopWatch.start(); | |||
//1.查出丽水市下的 区县 分别去初始化 表单和流程配置数据 | |||
List<RegionDTO> regions = regionCacheHelper.listChildren(RegionConst.RC_HZ, RegionConst.RL_CITY); | |||
if(CollUtil.isEmpty(regions)){ | |||
throw new BizException("丽水地区数据为空 任务结束!"); | |||
} | |||
for(RegionDTO region : regions){ | |||
log.info("当前初始化的是 【{}】 流程配置",region.getRegionName()); | |||
Integer[] processTypeList = TaskConstant.Wflow.APPLY_PROCESS_TYPE_LIST; | |||
for(Integer processType : processTypeList){ | |||
String formName = ProjectProcessType.getDesc(processType); | |||
WflowModelHistorysInsertDto models = new WflowModelHistorysInsertDto(); | |||
models.setGroupId(1); | |||
models.setProcessDefId("pd" + IdUtil.objectId()); | |||
models.setFormName(formName); | |||
models.setProcessType(processType); | |||
models.setRegionCode(region.getRegionCode()); | |||
String process = "{\"children\":{\"children\":{},\"id\":\"node_039152532706\",\"name\":\"审批人\",\"parentId\":\"root\",\"props\":{\"mode\":\"AND\",\"role\":[],\"refuse\":{\"type\":\"TO_END\",\"target\":\"\"},\"assignedOrg\":[{\"orgName\":\"数转办\",\"orgCode\":\"GO_3bc86256687a4884ae410af00682b762\",\"type\":\"DEFAULT\",\"processDefId\":\"\"}],\"sign\":false,\"assignedType\":\"ASSIGN_ORG\",\"assignedDept\":[]},\"type\":\"SUB\"},\"id\":\"root\",\"name\":\"发起人\",\"props\":{\"formPerms\":[],\"assignedUser\":[]},\"type\":\"ROOT\"}"; | |||
ProcessNode processNode = JSON.parseObject(process,ProcessNode.class); | |||
models.setProcess(processNode); | |||
models.setSettings("{\"sign\":false,\"admin\":[],\"notify\":{},\"commiter\":[]}"); | |||
models.setFormItems("[]"); | |||
String formId = processModelService.insertProcess(models); | |||
if(StringUtils.isNotBlank(formId)){ | |||
//初始的流程在部署表也存一份,用来查询 | |||
if(StringUtils.isNotBlank(processModelService.deployProcess(formId,null))){ | |||
log.info("当前区域 【{}】 流程名[{}] 流程数据已经保存成功",region.getRegionName(),formName); | |||
}else{ | |||
log.info("当前区域 【{}】 流程名[{}] 流程数据保存失败",region.getRegionName(),formName); | |||
} | |||
}else{ | |||
log.info("当前区域 【{}】流程名[{}] 流程数据保存失败",region.getRegionName(),formName); | |||
} | |||
} | |||
} | |||
stopWatch.stop(); | |||
log.info("=========== 初始化丽水二期 系统表单和流程配置 ======== 任务结束 {}s",stopWatch.getTotalTimeSeconds()); | |||
} | |||
public static class OrgProps { | |||
private String regionCode; | |||
private String orgCode; | |||
private String type; | |||
private String processDefId; | |||
private List<Node> subNode; | |||
public String getRegionCode() { | |||
return regionCode; | |||
} | |||
public void setRegionCode(String regionCode) { | |||
this.regionCode = regionCode; | |||
} | |||
public String getOrgCode() { | |||
return orgCode; | |||
} | |||
public void setOrgCode(String orgCode) { | |||
this.orgCode = orgCode; | |||
} | |||
public String getType() { | |||
return type; | |||
} | |||
public void setType(String type) { | |||
this.type = type; | |||
} | |||
public String getProcessDefId() { | |||
return processDefId; | |||
} | |||
public void setProcessDefId(String processDefId) { | |||
this.processDefId = processDefId; | |||
} | |||
public List<Node> getSubNode() { | |||
return subNode; | |||
} | |||
public void setSubNode(List<Node> subNode) { | |||
this.subNode = subNode; | |||
} | |||
} | |||
} |