🔖 Releasing / Version tags. 5.2

🔖 Releasing / Version tags. 5.2
This commit is contained in:
lbw committed 2023-09-13 10:28:40 +08:00
1 parent 95371f54a8
commit 2c6a700154
100 files changed
+507 -439

No files matched your search

+1 -1
View File
@@ -7,7 +7,7 @@
<parent> <parent>
<groupId>com.pig4cloud</groupId> <groupId>com.pig4cloud</groupId>
<artifactId>pigx-app-server</artifactId> <artifactId>pigx-app-server</artifactId>
<version>5.2.0-snapshot</version> <version>5.2.0</version>
</parent> </parent>
<artifactId>pigx-app-server-api</artifactId> <artifactId>pigx-app-server-api</artifactId>
+2 -2
View File
@@ -7,7 +7,7 @@
<parent> <parent>
<groupId>com.pig4cloud</groupId> <groupId>com.pig4cloud</groupId>
<artifactId>pigx-app-server</artifactId> <artifactId>pigx-app-server</artifactId>
<version>5.2.0-snapshot</version> <version>5.2.0</version>
</parent> </parent>
<artifactId>pigx-app-server-biz</artifactId> <artifactId>pigx-app-server-biz</artifactId>
@@ -62,7 +62,7 @@
<dependency> <dependency>
<groupId>com.pig4cloud</groupId> <groupId>com.pig4cloud</groupId>
<artifactId>pigx-app-server-api</artifactId> <artifactId>pigx-app-server-api</artifactId>
<version>5.2.0-snapshot</version> <version>5.2.0</version>
</dependency> </dependency>
<!--必备: log 依赖--> <!--必备: log 依赖-->
<dependency> <dependency>
@@ -47,9 +47,10 @@ public class AppArticleCollectController {
@GetMapping("/page") @GetMapping("/page")
public R getAppArticleCollectPage(@ParameterObject Page page) { public R getAppArticleCollectPage(@ParameterObject Page page) {
MPJLambdaWrapper<AppArticleCollectEntity> wrapper = new MPJLambdaWrapper<AppArticleCollectEntity>() MPJLambdaWrapper<AppArticleCollectEntity> wrapper = new MPJLambdaWrapper<AppArticleCollectEntity>()
.selectAll(AppArticleCollectEntity.class).select(AppArticleEntity::getTitle) .selectAll(AppArticleCollectEntity.class)
.leftJoin(AppArticleEntity.class, AppArticleEntity::getId, AppArticleCollectEntity::getArticleId) .select(AppArticleEntity::getTitle)
.eq(AppArticleCollectEntity::getUserId, SecurityUtils.getUser().getId()); .leftJoin(AppArticleEntity.class, AppArticleEntity::getId, AppArticleCollectEntity::getArticleId)
.eq(AppArticleCollectEntity::getUserId, SecurityUtils.getUser().getId());
return R.ok(appArticleCollectService.selectJoinListPage(page, AppArticleCollectEntity.class, wrapper)); return R.ok(appArticleCollectService.selectJoinListPage(page, AppArticleCollectEntity.class, wrapper));
} }
@@ -106,7 +107,8 @@ public class AppArticleCollectController {
public R removeByArticleId(@PathVariable String articleId) { public R removeByArticleId(@PathVariable String articleId) {
Long id = SecurityUtils.getUser().getId(); Long id = SecurityUtils.getUser().getId();
return R.ok(appArticleCollectService.remove(Wrappers.<AppArticleCollectEntity>lambdaQuery() return R.ok(appArticleCollectService.remove(Wrappers.<AppArticleCollectEntity>lambdaQuery()
.eq(AppArticleCollectEntity::getUserId, id).eq(AppArticleCollectEntity::getArticleId, articleId))); .eq(AppArticleCollectEntity::getUserId, id)
.eq(AppArticleCollectEntity::getArticleId, articleId)));
} }
/** /**
@@ -63,7 +63,7 @@ public class AppRoleController {
@GetMapping("/page") @GetMapping("/page")
public R getAppRolePage(Page page, AppRole appRole) { public R getAppRolePage(Page page, AppRole appRole) {
return R.ok(appRoleService.page(page, Wrappers.<AppRole>lambdaQuery() return R.ok(appRoleService.page(page, Wrappers.<AppRole>lambdaQuery()
.like(StrUtil.isNotBlank(appRole.getRoleName()), AppRole::getRoleName, appRole.getRoleName()))); .like(StrUtil.isNotBlank(appRole.getRoleName()), AppRole::getRoleName, appRole.getRoleName())));
} }
/** /**
@@ -63,8 +63,11 @@ public class AppUserController {
@Inner @Inner
@GetMapping("/info/{username}") @GetMapping("/info/{username}")
public R info(@PathVariable String username) { public R info(@PathVariable String username) {
AppUser user = appUserService.getOne(Wrappers.<AppUser>query().lambda().eq(AppUser::getUsername, username).or() AppUser user = appUserService.getOne(Wrappers.<AppUser>query()
.eq(AppUser::getPhone, username)); .lambda()
.eq(AppUser::getUsername, username)
.or()
.eq(AppUser::getPhone, username));
if (user == null) { if (user == null) {
return R.failed(MsgUtils.getMessage(ErrorCodes.APP_USER_USERINFO_EMPTY, username)); return R.failed(MsgUtils.getMessage(ErrorCodes.APP_USER_USERINFO_EMPTY, username));
} }
@@ -24,8 +24,9 @@ public class AppArticleCollectServiceImpl extends ServiceImpl<AppArticleCollectM
appArticleCollect.setUserId(id); appArticleCollect.setUserId(id);
this.saveOrUpdate(appArticleCollect, this.saveOrUpdate(appArticleCollect,
Wrappers.<AppArticleCollectEntity>lambdaQuery().eq(AppArticleCollectEntity::getUserId, id) Wrappers.<AppArticleCollectEntity>lambdaQuery()
.eq(AppArticleCollectEntity::getArticleId, appArticleCollect.getArticleId())); .eq(AppArticleCollectEntity::getUserId, id)
.eq(AppArticleCollectEntity::getArticleId, appArticleCollect.getArticleId()));
return Boolean.TRUE; return Boolean.TRUE;
} }
@@ -40,8 +40,8 @@ public class AppArticleServiceImpl extends ServiceImpl<AppArticleMapper, AppArti
// 查询是否收藏了 // 查询是否收藏了
if (Objects.nonNull(userId)) { if (Objects.nonNull(userId)) {
boolean exists = collectMapper.exists(Wrappers.<AppArticleCollectEntity>lambdaQuery()// boolean exists = collectMapper.exists(Wrappers.<AppArticleCollectEntity>lambdaQuery()//
.eq(AppArticleCollectEntity::getArticleId, appArticleEntity.getId())// .eq(AppArticleCollectEntity::getArticleId, appArticleEntity.getId())//
.eq(AppArticleCollectEntity::getUserId, userId)); .eq(AppArticleCollectEntity::getUserId, userId));
appArticleEntity.setCollect(exists); appArticleEntity.setCollect(exists);
} }
@@ -49,8 +49,10 @@ public class AppArticleServiceImpl extends ServiceImpl<AppArticleMapper, AppArti
Integer nowVisit = appArticleEntity.getVisit(); Integer nowVisit = appArticleEntity.getVisit();
appArticleEntity.setVisit(nowVisit + 1); appArticleEntity.setVisit(nowVisit + 1);
// 乐观锁 // 乐观锁
baseMapper.update(appArticleEntity, Wrappers.<AppArticleEntity>lambdaQuery().eq(AppArticleEntity::getId, id) baseMapper.update(appArticleEntity,
.eq(AppArticleEntity::getVisit, nowVisit)); Wrappers.<AppArticleEntity>lambdaQuery()
.eq(AppArticleEntity::getId, id)
.eq(AppArticleEntity::getVisit, nowVisit));
return appArticleEntity; return appArticleEntity;
} }
@@ -64,11 +66,11 @@ public class AppArticleServiceImpl extends ServiceImpl<AppArticleMapper, AppArti
public Page pageAndCname(Page page, AppArticleEntity appArticle) { public Page pageAndCname(Page page, AppArticleEntity appArticle) {
MPJLambdaWrapper<AppArticleEntity> wrapper = new MPJLambdaWrapper<>(); MPJLambdaWrapper<AppArticleEntity> wrapper = new MPJLambdaWrapper<>();
wrapper.selectAll(AppArticleEntity.class) wrapper.selectAll(AppArticleEntity.class)
.selectAs(AppArticleCategoryEntity::getName, AppArticleEntity.Fields.cname) .selectAs(AppArticleCategoryEntity::getName, AppArticleEntity.Fields.cname)
.leftJoin(AppArticleCategoryEntity.class, AppArticleCategoryEntity::getId, AppArticleEntity::getCid) .leftJoin(AppArticleCategoryEntity.class, AppArticleCategoryEntity::getId, AppArticleEntity::getCid)
.like(StrUtil.isNotBlank(appArticle.getAuthor()), AppArticleEntity::getAuthor, appArticle.getAuthor()) .like(StrUtil.isNotBlank(appArticle.getAuthor()), AppArticleEntity::getAuthor, appArticle.getAuthor())
.like(StrUtil.isNotBlank(appArticle.getTitle()), AppArticleEntity::getTitle, appArticle.getTitle()) .like(StrUtil.isNotBlank(appArticle.getTitle()), AppArticleEntity::getTitle, appArticle.getTitle())
.eq(Objects.nonNull(appArticle.getCid()), AppArticleEntity::getCid, appArticle.getCid()); .eq(Objects.nonNull(appArticle.getCid()), AppArticleEntity::getCid, appArticle.getCid());
return this.page(page, wrapper); return this.page(page, wrapper);
} }
@@ -40,7 +40,7 @@ public class AppIndexServiceImpl implements AppIndexService {
Map<String, Object> response = new LinkedHashMap<>(); Map<String, Object> response = new LinkedHashMap<>();
AppPageEntity appPageEntity = appPageMapper.selectById(1); AppPageEntity appPageEntity = appPageMapper.selectById(1);
List<AppArticleEntity> articleList = appArticleMapper List<AppArticleEntity> articleList = appArticleMapper
.selectList(Wrappers.<AppArticleEntity>lambdaQuery().orderByDesc(AppArticleEntity::getSort)); .selectList(Wrappers.<AppArticleEntity>lambdaQuery().orderByDesc(AppArticleEntity::getSort));
response.put("pages", appPageEntity); response.put("pages", appPageEntity);
response.put("article", articleList); response.put("article", articleList);
return response; return response;
@@ -54,7 +54,7 @@ public class AppMobileServiceImpl implements AppMobileService {
@Override @Override
public R<Boolean> sendSmsCode(String mobile) { public R<Boolean> sendSmsCode(String mobile) {
Object codeObj = redisTemplate.opsForValue() Object codeObj = redisTemplate.opsForValue()
.get(CacheConstants.DEFAULT_CODE_KEY + LoginTypeEnum.APPSMS.getType() + StringPool.AT + mobile); .get(CacheConstants.DEFAULT_CODE_KEY + LoginTypeEnum.APPSMS.getType() + StringPool.AT + mobile);
if (codeObj != null) { if (codeObj != null) {
log.info("手机号验证码未过期:{},{}", mobile, codeObj); log.info("手机号验证码未过期:{},{}", mobile, codeObj);
@@ -63,9 +63,9 @@ public class AppMobileServiceImpl implements AppMobileService {
String code = RandomUtil.randomNumbers(Integer.parseInt(SecurityConstants.CODE_SIZE)); String code = RandomUtil.randomNumbers(Integer.parseInt(SecurityConstants.CODE_SIZE));
log.debug("手机号生成验证码成功:{},{}", mobile, code); log.debug("手机号生成验证码成功:{},{}", mobile, code);
redisTemplate.opsForValue().set( redisTemplate.opsForValue()
CacheConstants.DEFAULT_CODE_KEY + LoginTypeEnum.APPSMS.getType() + StringPool.AT + mobile, code, .set(CacheConstants.DEFAULT_CODE_KEY + LoginTypeEnum.APPSMS.getType() + StringPool.AT + mobile, code,
SecurityConstants.CODE_TIME, TimeUnit.SECONDS); SecurityConstants.CODE_TIME, TimeUnit.SECONDS);
return R.ok(Boolean.TRUE, code); return R.ok(Boolean.TRUE, code);
} }
@@ -77,8 +77,9 @@ public class AppRoleServiceImpl extends ServiceImpl<AppRoleMapper, AppRole> impl
for (AppRoleExcelVO excel : excelVOList) { for (AppRoleExcelVO excel : excelVOList) {
Set<String> errorMsg = new HashSet<>(); Set<String> errorMsg = new HashSet<>();
// 检验角色名称或者角色编码是否存在 // 检验角色名称或者角色编码是否存在
boolean existRole = roleList.stream().anyMatch(appRole -> excel.getRoleName().equals(appRole.getRoleName()) boolean existRole = roleList.stream()
|| excel.getRoleCode().equals(appRole.getRoleCode())); .anyMatch(appRole -> excel.getRoleName().equals(appRole.getRoleName())
|| excel.getRoleCode().equals(appRole.getRoleCode()));
if (existRole) { if (existRole) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.SYS_ROLE_NAMEORCODE_EXISTING, excel.getRoleName(), errorMsg.add(MsgUtils.getMessage(ErrorCodes.SYS_ROLE_NAMEORCODE_EXISTING, excel.getRoleName(),
@@ -159,8 +159,10 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
AppUserInfo info = new AppUserInfo(); AppUserInfo info = new AppUserInfo();
info.setAppUser(user); info.setAppUser(user);
// 设置角色列表 (ID) // 设置角色列表 (ID)
List<Long> roleIds = appRoleService.findRolesByUserId(user.getUserId()).stream().map(AppRole::getRoleId) List<Long> roleIds = appRoleService.findRolesByUserId(user.getUserId())
.collect(Collectors.toList()); .stream()
.map(AppRole::getRoleId)
.collect(Collectors.toList());
info.setRoles(ArrayUtil.toArray(roleIds, Long.class)); info.setRoles(ArrayUtil.toArray(roleIds, Long.class));
// 设置权限列表(menu.permission) // 设置权限列表(menu.permission)
@@ -211,7 +213,7 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
} }
// 删除用户关联表 // 删除用户关联表
this.appUserRoleService this.appUserRoleService
.remove(Wrappers.<AppUserRole>lambdaQuery().in(AppUserRole::getUserId, CollUtil.toList(ids))); .remove(Wrappers.<AppUserRole>lambdaQuery().in(AppUserRole::getUserId, CollUtil.toList(ids)));
this.removeBatchByIds(CollUtil.toList(ids)); this.removeBatchByIds(CollUtil.toList(ids));
@@ -222,7 +224,7 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
@Override @Override
public R registerAppUser(AppUserDTO appUser) { public R registerAppUser(AppUserDTO appUser) {
List<AppUser> appUserList = baseMapper List<AppUser> appUserList = baseMapper
.selectList(Wrappers.<AppUser>lambdaQuery().eq(AppUser::getPhone, appUser.getPhone())); .selectList(Wrappers.<AppUser>lambdaQuery().eq(AppUser::getPhone, appUser.getPhone()));
if (CollUtil.isNotEmpty(appUserList)) { if (CollUtil.isNotEmpty(appUserList)) {
return R.failed("手机号已注册,请使用验证码直接登录"); return R.failed("手机号已注册,请使用验证码直接登录");
@@ -264,7 +266,7 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
Set<String> errorMsg = new HashSet<>(); Set<String> errorMsg = new HashSet<>();
// 校验用户名是否存在 // 校验用户名是否存在
boolean exsitUserName = userList.stream() boolean exsitUserName = userList.stream()
.anyMatch(sysUser -> excel.getUsername().equals(sysUser.getUsername())); .anyMatch(sysUser -> excel.getUsername().equals(sysUser.getUsername()));
if (exsitUserName) { if (exsitUserName) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.SYS_USER_USERNAME_EXISTING, excel.getUsername())); errorMsg.add(MsgUtils.getMessage(ErrorCodes.SYS_USER_USERNAME_EXISTING, excel.getUsername()));
@@ -273,8 +275,8 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
// 判断输入的角色名称列表是否合法 // 判断输入的角色名称列表是否合法
List<String> roleNameList = StrUtil.split(excel.getRoleNameList(), StrUtil.COMMA); List<String> roleNameList = StrUtil.split(excel.getRoleNameList(), StrUtil.COMMA);
List<AppRole> roleCollList = roleList.stream() List<AppRole> roleCollList = roleList.stream()
.filter(role -> roleNameList.stream().anyMatch(name -> role.getRoleName().equals(name))) .filter(role -> roleNameList.stream().anyMatch(name -> role.getRoleName().equals(name)))
.collect(Collectors.toList()); .collect(Collectors.toList());
if (roleCollList.size() != roleNameList.size()) { if (roleCollList.size() != roleNameList.size()) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.SYS_ROLE_ROLENAME_INEXISTENCE, excel.getRoleNameList())); errorMsg.add(MsgUtils.getMessage(ErrorCodes.SYS_ROLE_ROLENAME_INEXISTENCE, excel.getRoleNameList()));
+1 -1
View File
@@ -7,7 +7,7 @@
<parent> <parent>
<groupId>com.pig4cloud</groupId> <groupId>com.pig4cloud</groupId>
<artifactId>pigx</artifactId> <artifactId>pigx</artifactId>
<version>5.2.0-snapshot</version> <version>5.2.0</version>
</parent> </parent>
<artifactId>pigx-app-server</artifactId> <artifactId>pigx-app-server</artifactId>
+1 -1
View File
@@ -24,7 +24,7 @@
<parent> <parent>
<groupId>com.pig4cloud</groupId> <groupId>com.pig4cloud</groupId>
<artifactId>pigx</artifactId> <artifactId>pigx</artifactId>
<version>5.2.0-snapshot</version> <version>5.2.0</version>
</parent> </parent>
<artifactId>pigx-auth</artifactId> <artifactId>pigx-auth</artifactId>
+1 -1
View File
@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>com.pig4cloud</groupId> <groupId>com.pig4cloud</groupId>
<artifactId>pigx-common</artifactId> <artifactId>pigx-common</artifactId>
<version>5.2.0-snapshot</version> <version>5.2.0</version>
</parent> </parent>
<artifactId>pigx-common-audit</artifactId> <artifactId>pigx-common-audit</artifactId>
+1 -1
View File
@@ -17,7 +17,7 @@
<description>pigx 公共版本控制</description> <description>pigx 公共版本控制</description>
<properties> <properties>
<pigx.version>5.2.0-snapshot</pigx.version> <pigx.version>5.2.0</pigx.version>
<mybatis-plus.version>3.5.3.2</mybatis-plus.version> <mybatis-plus.version>3.5.3.2</mybatis-plus.version>
<mybatis-plus-join.version>1.4.5</mybatis-plus-join.version> <mybatis-plus-join.version>1.4.5</mybatis-plus-join.version>
<dynamic-ds.version>4.1.3</dynamic-ds.version> <dynamic-ds.version>4.1.3</dynamic-ds.version>
+1 -1
View File
@@ -24,7 +24,7 @@
<parent> <parent>
<groupId>com.pig4cloud</groupId> <groupId>com.pig4cloud</groupId>
<artifactId>pigx-common</artifactId> <artifactId>pigx-common</artifactId>
<version>5.2.0-snapshot</version> <version>5.2.0</version>
</parent> </parent>
<artifactId>pigx-common-core</artifactId> <artifactId>pigx-common-core</artifactId>
+1 -1
View File
@@ -24,7 +24,7 @@
<parent> <parent>
<groupId>com.pig4cloud</groupId> <groupId>com.pig4cloud</groupId>
<artifactId>pigx-common</artifactId> <artifactId>pigx-common</artifactId>
<version>5.2.0-snapshot</version> <version>5.2.0</version>
</parent> </parent>
<artifactId>pigx-common-data</artifactId> <artifactId>pigx-common-data</artifactId>
@@ -44,8 +44,7 @@ public class DataScopeInnerInterceptor implements DataScopeInterceptor {
// 返回true 不拦截直接返回原始 SQL (只针对 COUNT 查询) // 返回true 不拦截直接返回原始 SQL (只针对 COUNT 查询)
if (dataScopeHandle.calcScope(dataScope) && DataScopeFuncEnum.COUNT.equals(dataScope.getFunc())) { if (dataScopeHandle.calcScope(dataScope) && DataScopeFuncEnum.COUNT.equals(dataScope.getFunc())) {
mpBs.sql(String.format("SELECT %s FROM (%s) temp_data_scope", mpBs.sql(String.format("SELECT %s FROM (%s) temp_data_scope", dataScope.getFunc().getType(), originalSql));
dataScope.getFunc().getType(), originalSql));
return; return;
} }
+1 -1
View File
@@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>pigx-common</artifactId> <artifactId>pigx-common</artifactId>
<groupId>com.pig4cloud</groupId> <groupId>com.pig4cloud</groupId>
<version>5.2.0-snapshot</version> <version>5.2.0</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
+1 -1
View File
@@ -24,7 +24,7 @@
<parent> <parent>
<groupId>com.pig4cloud</groupId> <groupId>com.pig4cloud</groupId>
<artifactId>pigx-common</artifactId> <artifactId>pigx-common</artifactId>
<version>5.2.0-snapshot</version> <version>5.2.0</version>
</parent> </parent>
<artifactId>pigx-common-encrypt-api</artifactId> <artifactId>pigx-common-encrypt-api</artifactId>
+1 -1
View File
@@ -24,7 +24,7 @@
<parent> <parent>
<groupId>com.pig4cloud</groupId> <groupId>com.pig4cloud</groupId>
<artifactId>pigx-common</artifactId> <artifactId>pigx-common</artifactId>
<version>5.2.0-snapshot</version> <version>5.2.0</version>
</parent> </parent>
<artifactId>pigx-common-excel</artifactId> <artifactId>pigx-common-excel</artifactId>
@@ -63,7 +63,7 @@ public class ResponseExcelAutoConfiguration {
@PostConstruct @PostConstruct
public void setReturnValueHandlers() { public void setReturnValueHandlers() {
List<HandlerMethodReturnValueHandler> returnValueHandlers = requestMappingHandlerAdapter List<HandlerMethodReturnValueHandler> returnValueHandlers = requestMappingHandlerAdapter
.getReturnValueHandlers(); .getReturnValueHandlers();
List<HandlerMethodReturnValueHandler> newHandlers = new ArrayList<>(); List<HandlerMethodReturnValueHandler> newHandlers = new ArrayList<>();
newHandlers.add(responseExcelReturnValueHandler); newHandlers.add(responseExcelReturnValueHandler);
@@ -71,12 +71,16 @@ public class RequestExcelArgumentResolver implements HandlerMethodArgumentResolv
Class<?> excelModelClass = ResolvableType.forMethodParameter(parameter).getGeneric(0).resolve(); Class<?> excelModelClass = ResolvableType.forMethodParameter(parameter).getGeneric(0).resolve();
// 这里需要指定读用哪个 class 去读,然后读取第一个 sheet 文件流会自动关闭 // 这里需要指定读用哪个 class 去读,然后读取第一个 sheet 文件流会自动关闭
EasyExcel.read(inputStream, excelModelClass, readListener).registerConverter(LocalDateStringConverter.INSTANCE) EasyExcel.read(inputStream, excelModelClass, readListener)
.registerConverter(LocalTimeStringConverter.INSTANCE) .registerConverter(LocalDateStringConverter.INSTANCE)
.registerConverter(LocalDateTimeStringConverter.INSTANCE) .registerConverter(LocalTimeStringConverter.INSTANCE)
.registerConverter(LongStringConverter.INSTANCE).registerConverter(StringArrayConverter.INSTANCE) .registerConverter(LocalDateTimeStringConverter.INSTANCE)
.ignoreEmptyRow(requestExcel.ignoreEmptyRow()).sheet().headRowNumber(requestExcel.headRowNumber()) .registerConverter(LongStringConverter.INSTANCE)
.doRead(); .registerConverter(StringArrayConverter.INSTANCE)
.ignoreEmptyRow(requestExcel.ignoreEmptyRow())
.sheet()
.headRowNumber(requestExcel.headRowNumber())
.doRead();
// 校验失败的数据处理 交给 BindResult // 校验失败的数据处理 交给 BindResult
WebDataBinder dataBinder = webDataBinderFactory.createBinder(webRequest, readListener.getErrors(), "excel"); WebDataBinder dataBinder = webDataBinderFactory.createBinder(webRequest, readListener.getErrors(), "excel");
@@ -51,8 +51,10 @@ public class ResponseExcelReturnValueHandler implements HandlerMethodReturnValue
Assert.state(responseExcel != null, "No @ResponseExcel"); Assert.state(responseExcel != null, "No @ResponseExcel");
mavContainer.setRequestHandled(true); mavContainer.setRequestHandled(true);
sheetWriteHandlerList.stream().filter(handler -> handler.support(o)).findFirst() sheetWriteHandlerList.stream()
.ifPresent(handler -> handler.export(o, response, responseExcel)); .filter(handler -> handler.support(o))
.findFirst()
.ifPresent(handler -> handler.export(o, response, responseExcel));
} }
} }
@@ -41,7 +41,7 @@ public enum LocalDateStringConverter implements Converter<LocalDate> {
} }
else { else {
DateTimeFormatter formatter = DateTimeFormatter DateTimeFormatter formatter = DateTimeFormatter
.ofPattern(contentProperty.getDateTimeFormatProperty().getFormat()); .ofPattern(contentProperty.getDateTimeFormatProperty().getFormat());
return LocalDate.parse(cellData.getStringValue(), formatter); return LocalDate.parse(cellData.getStringValue(), formatter);
} }
} }
@@ -41,7 +41,7 @@ public enum LocalTimeStringConverter implements Converter<LocalTime> {
} }
else { else {
DateTimeFormatter formatter = DateTimeFormatter DateTimeFormatter formatter = DateTimeFormatter
.ofPattern(contentProperty.getDateTimeFormatProperty().getFormat()); .ofPattern(contentProperty.getDateTimeFormatProperty().getFormat());
return LocalTime.parse(cellData.getStringValue(), formatter); return LocalTime.parse(cellData.getStringValue(), formatter);
} }
} }
@@ -81,15 +81,16 @@ public abstract class AbstractSheetWriteHandler implements SheetWriteHandler, Ap
public void export(Object o, HttpServletResponse response, ResponseExcel responseExcel) { public void export(Object o, HttpServletResponse response, ResponseExcel responseExcel) {
check(responseExcel); check(responseExcel);
RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes(); RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
String name = (String) Objects.requireNonNull(requestAttributes).getAttribute(DynamicNameAspect.EXCEL_NAME_KEY, String name = (String) Objects.requireNonNull(requestAttributes)
RequestAttributes.SCOPE_REQUEST); .getAttribute(DynamicNameAspect.EXCEL_NAME_KEY, RequestAttributes.SCOPE_REQUEST);
if (name == null) { if (name == null) {
name = UUID.randomUUID().toString(); name = UUID.randomUUID().toString();
} }
String fileName = String.format("%s%s", URLEncoder.encode(name, "UTF-8"), responseExcel.suffix().getValue()); String fileName = String.format("%s%s", URLEncoder.encode(name, "UTF-8"), responseExcel.suffix().getValue());
// 根据实际的文件类型找到对应的 contentType // 根据实际的文件类型找到对应的 contentType
String contentType = MediaTypeFactory.getMediaType(fileName).map(MediaType::toString) String contentType = MediaTypeFactory.getMediaType(fileName)
.orElse("application/vnd.ms-excel"); .map(MediaType::toString)
.orElse("application/vnd.ms-excel");
response.setContentType(contentType); response.setContentType(contentType);
response.setCharacterEncoding("utf-8"); response.setCharacterEncoding("utf-8");
response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename*=utf-8''" + fileName); response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename*=utf-8''" + fileName);
@@ -105,11 +106,14 @@ public abstract class AbstractSheetWriteHandler implements SheetWriteHandler, Ap
@SneakyThrows(IOException.class) @SneakyThrows(IOException.class)
public ExcelWriter getExcelWriter(HttpServletResponse response, ResponseExcel responseExcel) { public ExcelWriter getExcelWriter(HttpServletResponse response, ResponseExcel responseExcel) {
ExcelWriterBuilder writerBuilder = EasyExcel.write(response.getOutputStream()) ExcelWriterBuilder writerBuilder = EasyExcel.write(response.getOutputStream())
.registerConverter(LocalTimeStringConverter.INSTANCE) .registerConverter(LocalTimeStringConverter.INSTANCE)
.registerConverter(LocalDateStringConverter.INSTANCE) .registerConverter(LocalDateStringConverter.INSTANCE)
.registerConverter(LocalDateTimeStringConverter.INSTANCE) .registerConverter(LocalDateTimeStringConverter.INSTANCE)
.registerConverter(LongStringConverter.INSTANCE).registerConverter(StringArrayConverter.INSTANCE) .registerConverter(LongStringConverter.INSTANCE)
.autoCloseStream(true).excelType(responseExcel.suffix()).inMemory(responseExcel.inMemory()); .registerConverter(StringArrayConverter.INSTANCE)
.autoCloseStream(true)
.excelType(responseExcel.suffix())
.inMemory(responseExcel.inMemory());
if (StringUtils.hasText(responseExcel.password())) { if (StringUtils.hasText(responseExcel.password())) {
writerBuilder.password(responseExcel.password()); writerBuilder.password(responseExcel.password());
@@ -35,8 +35,9 @@ public class DefaultAnalysisEventListener extends ListAnalysisEventListener<Obje
Set<ConstraintViolation<Object>> violations = Validators.validate(o); Set<ConstraintViolation<Object>> violations = Validators.validate(o);
if (!violations.isEmpty()) { if (!violations.isEmpty()) {
Set<String> messageSet = violations.stream().map(ConstraintViolation::getMessage) Set<String> messageSet = violations.stream()
.collect(Collectors.toSet()); .map(ConstraintViolation::getMessage)
.collect(Collectors.toSet());
errorMessageList.add(new ErrorMessage(lineNum, messageSet)); errorMessageList.add(new ErrorMessage(lineNum, messageSet));
} }
else { else {
@@ -51,8 +51,8 @@ public class I18nHeaderCellWriteHandler implements CellWriteHandler {
if (CollectionUtils.isNotEmpty(originHeadNameList)) { if (CollectionUtils.isNotEmpty(originHeadNameList)) {
// 国际化处理 // 国际化处理
List<String> i18nHeadNames = originHeadNameList.stream() List<String> i18nHeadNames = originHeadNameList.stream()
.map(headName -> propertyPlaceholderHelper.replacePlaceholders(headName, placeholderResolver)) .map(headName -> propertyPlaceholderHelper.replacePlaceholders(headName, placeholderResolver))
.collect(Collectors.toList()); .collect(Collectors.toList());
head.setHeadNameList(i18nHeadNames); head.setHeadNameList(i18nHeadNames);
} }
} }
+1 -1
View File
@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>com.pig4cloud</groupId> <groupId>com.pig4cloud</groupId>
<artifactId>pigx-common</artifactId> <artifactId>pigx-common</artifactId>
<version>5.2.0-snapshot</version> <version>5.2.0</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
@@ -91,7 +91,8 @@ public class PigxFeignClientsRegistrar
continue; continue;
} }
registerClientConfiguration(registry, getClientName(attributes), className, attributes.get("configuration")); registerClientConfiguration(registry, getClientName(attributes), className,
attributes.get("configuration"));
validate(attributes); validate(attributes);
BeanDefinitionBuilder definition = BeanDefinitionBuilder BeanDefinitionBuilder definition = BeanDefinitionBuilder
@@ -255,7 +256,7 @@ public class PigxFeignClientsRegistrar
} }
private void registerClientConfiguration(BeanDefinitionRegistry registry, Object name, Object className, private void registerClientConfiguration(BeanDefinitionRegistry registry, Object name, Object className,
Object configuration) { Object configuration) {
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(FeignClientSpecification.class); BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(FeignClientSpecification.class);
builder.addConstructorArgValue(name); builder.addConstructorArgValue(name);
builder.addConstructorArgValue(className); builder.addConstructorArgValue(className);
+1 -1
View File
@@ -24,7 +24,7 @@
<parent> <parent>
<groupId>com.pig4cloud</groupId> <groupId>com.pig4cloud</groupId>
<artifactId>pigx-common</artifactId> <artifactId>pigx-common</artifactId>
<version>5.2.0-snapshot</version> <version>5.2.0</version>
</parent> </parent>
<artifactId>pigx-common-gateway</artifactId> <artifactId>pigx-common-gateway</artifactId>
@@ -65,8 +65,8 @@ public class VersionGrayLoadBalancer implements GrayLoadBalancer {
if (StrUtil.isBlank(reqVersion)) { if (StrUtil.isBlank(reqVersion)) {
// 过滤出不含VERSION实例 // 过滤出不含VERSION实例
List<ServiceInstance> versionInstanceList = instances.stream() List<ServiceInstance> versionInstanceList = instances.stream()
.filter(instance -> !instance.getMetadata().containsKey(CommonConstants.VERSION)) .filter(instance -> !instance.getMetadata().containsKey(CommonConstants.VERSION))
.collect(Collectors.toList()); .collect(Collectors.toList());
if (CollUtil.isEmpty(versionInstanceList)) { if (CollUtil.isEmpty(versionInstanceList)) {
// 根据权重获取实例 // 根据权重获取实例
return randomByWeight(instances); return randomByWeight(instances);
@@ -76,9 +76,9 @@ public class VersionGrayLoadBalancer implements GrayLoadBalancer {
} }
// 遍历可以实例元数据,若匹配则返回此实例 // 遍历可以实例元数据,若匹配则返回此实例
List<ServiceInstance> availableList = instances.stream() List<ServiceInstance> availableList = instances.stream()
.filter(instance -> reqVersion .filter(instance -> reqVersion
.equalsIgnoreCase(MapUtil.getStr(instance.getMetadata(), CommonConstants.VERSION))) .equalsIgnoreCase(MapUtil.getStr(instance.getMetadata(), CommonConstants.VERSION)))
.collect(Collectors.toList()); .collect(Collectors.toList());
if (CollUtil.isEmpty(availableList)) { if (CollUtil.isEmpty(availableList)) {
// 根据权重获取实例 // 根据权重获取实例
return randomByWeight(instances); return randomByWeight(instances);
+1 -1
View File
@@ -24,7 +24,7 @@
<parent> <parent>
<groupId>com.pig4cloud</groupId> <groupId>com.pig4cloud</groupId>
<artifactId>pigx-common</artifactId> <artifactId>pigx-common</artifactId>
<version>5.2.0-snapshot</version> <version>5.2.0</version>
</parent> </parent>
<artifactId>pigx-common-gray</artifactId> <artifactId>pigx-common-gray</artifactId>
+1 -1
View File
@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>com.pig4cloud</groupId> <groupId>com.pig4cloud</groupId>
<artifactId>pigx-common</artifactId> <artifactId>pigx-common</artifactId>
<version>5.2.0-snapshot</version> <version>5.2.0</version>
</parent> </parent>
<artifactId>pigx-common-idempotent</artifactId> <artifactId>pigx-common-idempotent</artifactId>
+1 -1
View File
@@ -24,7 +24,7 @@
<parent> <parent>
<groupId>com.pig4cloud</groupId> <groupId>com.pig4cloud</groupId>
<artifactId>pigx-common</artifactId> <artifactId>pigx-common</artifactId>
<version>5.2.0-snapshot</version> <version>5.2.0</version>
</parent> </parent>
<artifactId>pigx-common-job</artifactId> <artifactId>pigx-common-job</artifactId>
+1 -1
View File
@@ -24,7 +24,7 @@
<parent> <parent>
<groupId>com.pig4cloud</groupId> <groupId>com.pig4cloud</groupId>
<artifactId>pigx-common</artifactId> <artifactId>pigx-common</artifactId>
<version>5.2.0-snapshot</version> <version>5.2.0</version>
</parent> </parent>
<artifactId>pigx-common-log</artifactId> <artifactId>pigx-common-log</artifactId>
+1 -1
View File
@@ -6,7 +6,7 @@
<parent> <parent>
<groupId>com.pig4cloud</groupId> <groupId>com.pig4cloud</groupId>
<artifactId>pigx-common</artifactId> <artifactId>pigx-common</artifactId>
<version>5.2.0-snapshot</version> <version>5.2.0</version>
</parent> </parent>
<artifactId>pigx-common-oss</artifactId> <artifactId>pigx-common-oss</artifactId>
+1 -1
View File
@@ -23,7 +23,7 @@
<parent> <parent>
<groupId>com.pig4cloud</groupId> <groupId>com.pig4cloud</groupId>
<artifactId>pigx-common</artifactId> <artifactId>pigx-common</artifactId>
<version>5.2.0-snapshot</version> <version>5.2.0</version>
</parent> </parent>
<artifactId>pigx-common-seata</artifactId> <artifactId>pigx-common-seata</artifactId>
+1 -1
View File
@@ -23,7 +23,7 @@
<parent> <parent>
<groupId>com.pig4cloud</groupId> <groupId>com.pig4cloud</groupId>
<artifactId>pigx-common</artifactId> <artifactId>pigx-common</artifactId>
<version>5.2.0-snapshot</version> <version>5.2.0</version>
</parent> </parent>
<artifactId>pigx-common-security</artifactId> <artifactId>pigx-common-security</artifactId>
+1 -1
View File
@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>com.pig4cloud</groupId> <groupId>com.pig4cloud</groupId>
<artifactId>pigx-common</artifactId> <artifactId>pigx-common</artifactId>
<version>5.2.0-snapshot</version> <version>5.2.0</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
+1 -1
View File
@@ -6,7 +6,7 @@
<parent> <parent>
<groupId>com.pig4cloud</groupId> <groupId>com.pig4cloud</groupId>
<artifactId>pigx-common</artifactId> <artifactId>pigx-common</artifactId>
<version>5.2.0-snapshot</version> <version>5.2.0</version>
</parent> </parent>
<artifactId>pigx-common-sequence</artifactId> <artifactId>pigx-common-sequence</artifactId>
+1 -1
View File
@@ -24,7 +24,7 @@
<parent> <parent>
<groupId>com.pig4cloud</groupId> <groupId>com.pig4cloud</groupId>
<artifactId>pigx-common</artifactId> <artifactId>pigx-common</artifactId>
<version>5.2.0-snapshot</version> <version>5.2.0</version>
</parent> </parent>
<artifactId>pigx-common-swagger</artifactId> <artifactId>pigx-common-swagger</artifactId>
+1 -1
View File
@@ -6,7 +6,7 @@
<parent> <parent>
<groupId>com.pig4cloud</groupId> <groupId>com.pig4cloud</groupId>
<artifactId>pigx-common</artifactId> <artifactId>pigx-common</artifactId>
<version>5.2.0-snapshot</version> <version>5.2.0</version>
</parent> </parent>
<artifactId>pigx-common-websocket</artifactId> <artifactId>pigx-common-websocket</artifactId>
+1 -1
View File
@@ -6,7 +6,7 @@
<parent> <parent>
<groupId>com.pig4cloud</groupId> <groupId>com.pig4cloud</groupId>
<artifactId>pigx-common</artifactId> <artifactId>pigx-common</artifactId>
<version>5.2.0-snapshot</version> <version>5.2.0</version>
</parent> </parent>
<artifactId>pigx-common-xss</artifactId> <artifactId>pigx-common-xss</artifactId>
+1 -1
View File
@@ -24,7 +24,7 @@
<parent> <parent>
<groupId>com.pig4cloud</groupId> <groupId>com.pig4cloud</groupId>
<artifactId>pigx</artifactId> <artifactId>pigx</artifactId>
<version>5.2.0-snapshot</version> <version>5.2.0</version>
</parent> </parent>
<artifactId>pigx-common</artifactId> <artifactId>pigx-common</artifactId>
@@ -7,7 +7,7 @@
<parent> <parent>
<groupId>com.pig4cloud</groupId> <groupId>com.pig4cloud</groupId>
<artifactId>pigx-flow-engine</artifactId> <artifactId>pigx-flow-engine</artifactId>
<version>5.2.0-snapshot</version> <version>5.2.0</version>
</parent> </parent>
<artifactId>pigx-flow-engine-api</artifactId> <artifactId>pigx-flow-engine-api</artifactId>
@@ -7,7 +7,7 @@
<parent> <parent>
<groupId>com.pig4cloud</groupId> <groupId>com.pig4cloud</groupId>
<artifactId>pigx-flow-engine</artifactId> <artifactId>pigx-flow-engine</artifactId>
<version>5.2.0-snapshot</version> <version>5.2.0</version>
</parent> </parent>
<artifactId>pigx-flow-engine-biz</artifactId> <artifactId>pigx-flow-engine-biz</artifactId>
@@ -28,9 +28,9 @@ import java.util.List;
*/ */
@Slf4j @Slf4j
public class ModelUtil { public class ModelUtil {
/** /**
* 构建模型 * 构建模型
*
* @param nodeDto 前端传输节点 * @param nodeDto 前端传输节点
* @return * @return
*/ */
@@ -42,17 +42,16 @@ public class ModelUtil {
process.setId(flowId); process.setId(flowId);
process.setName(processName); process.setName(processName);
//流程监听器 // 流程监听器
ArrayList<EventListener> eventListeners = new ArrayList<>(); ArrayList<EventListener> eventListeners = new ArrayList<>();
{ {
//流程实例监听器 // 流程实例监听器
EventListener eventListener = new EventListener(); EventListener eventListener = new EventListener();
eventListener.setImplementationType("class"); eventListener.setImplementationType("class");
eventListener.setImplementation(FlowProcessEventListener.class.getCanonicalName()); eventListener.setImplementation(FlowProcessEventListener.class.getCanonicalName());
eventListeners.add(eventListener); eventListeners.add(eventListener);
} }
@@ -60,24 +59,20 @@ public class ModelUtil {
NodeUtil.addEndNode(nodeDto); NodeUtil.addEndNode(nodeDto);
// 创建所有的节点
//创建所有的节点
buildAllNode(process, nodeDto, flowId); buildAllNode(process, nodeDto, flowId);
//创建所有的内部节点连接线 // 创建所有的内部节点连接线
buildAllNodeInnerSequence(process, nodeDto, flowId); buildAllNodeInnerSequence(process, nodeDto, flowId);
//创建节点间连线 // 创建节点间连线
buildAllNodeOuterSequence(process, nodeDto, null); buildAllNodeOuterSequence(process, nodeDto, null);
//处理分支和下级连线 // 处理分支和下级连线
bpmnModel.addProcess(process); bpmnModel.addProcess(process);
return bpmnModel; return bpmnModel;
} }
/** /**
* 先创建所有的节点 * 先创建所有的节点
*
* @param process * @param process
* @param nodeDto * @param nodeDto
* @param flowId * @param flowId
@@ -87,7 +82,6 @@ public class ModelUtil {
return; return;
} }
List<FlowElement> flowElementList = buildNode(nodeDto, flowId); List<FlowElement> flowElementList = buildNode(nodeDto, flowId);
for (FlowElement flowElement : flowElementList) { for (FlowElement flowElement : flowElementList) {
if (process.getFlowElement(flowElement.getId()) == null) { if (process.getFlowElement(flowElement.getId()) == null) {
@@ -95,36 +89,33 @@ public class ModelUtil {
} }
} }
//子节点 // 子节点
Node children = nodeDto.getChildren(); Node children = nodeDto.getChildren();
if (NodeTypeEnum.getByValue(nodeDto.getType()).getBranch()) { if (NodeTypeEnum.getByValue(nodeDto.getType()).getBranch()) {
//条件分支 // 条件分支
List<Node> branchs = nodeDto.getConditionNodes(); List<Node> branchs = nodeDto.getConditionNodes();
for (Node branch : branchs) { for (Node branch : branchs) {
buildAllNode(process, branch.getChildren(), buildAllNode(process, branch.getChildren(), flowId);
flowId);
} }
if (NodeUtil.isNode(children)) { if (NodeUtil.isNode(children)) {
buildAllNode(process, children, flowId); buildAllNode(process, children, flowId);
} }
} else { }
else {
if (NodeUtil.isNode(children)) { if (NodeUtil.isNode(children)) {
buildAllNode(process, children, flowId); buildAllNode(process, children, flowId);
} }
} }
} }
/** /**
* 先创建所有的内部节点连接线 * 先创建所有的内部节点连接线
*
* @param process * @param process
* @param nodeDto * @param nodeDto
* @param flowId * @param flowId
@@ -134,41 +125,37 @@ public class ModelUtil {
return; return;
} }
//画内部线 // 画内部线
List<SequenceFlow> flowList = buildInnerSequenceFlow(nodeDto, flowId); List<SequenceFlow> flowList = buildInnerSequenceFlow(nodeDto, flowId);
for (SequenceFlow sequenceFlow : flowList) { for (SequenceFlow sequenceFlow : flowList) {
process.addFlowElement(sequenceFlow); process.addFlowElement(sequenceFlow);
} }
//子节点 // 子节点
Node children = nodeDto.getChildren(); Node children = nodeDto.getChildren();
if (NodeTypeEnum.getByValue(nodeDto.getType()).getBranch() ) { if (NodeTypeEnum.getByValue(nodeDto.getType()).getBranch()) {
//条件分支 // 条件分支
List<Node> branchs = nodeDto.getConditionNodes(); List<Node> branchs = nodeDto.getConditionNodes();
for (Node branch : branchs) { for (Node branch : branchs) {
buildAllNodeInnerSequence(process, branch.getChildren(), buildAllNodeInnerSequence(process, branch.getChildren(), flowId);
flowId);
} }
if (NodeUtil.isNode(children)) { if (NodeUtil.isNode(children)) {
buildAllNodeInnerSequence(process, children, flowId); buildAllNodeInnerSequence(process, children, flowId);
} }
} else { }
else {
if (NodeUtil.isNode(children)) { if (NodeUtil.isNode(children)) {
buildAllNodeInnerSequence(process, children, flowId); buildAllNodeInnerSequence(process, children, flowId);
} }
} }
} }
/** /**
* 递归创建节点间连线 * 递归创建节点间连线
*
* @param process 流程 * @param process 流程
* @param nodeDto 节点对象 * @param nodeDto 节点对象
* @param nextId * @param nextId
@@ -179,85 +166,81 @@ public class ModelUtil {
return; return;
} }
//子节点 // 子节点
Node children = nodeDto.getChildren(); Node children = nodeDto.getChildren();
if (NodeTypeEnum.getByValue(nodeDto.getType()).getBranch() ) { if (NodeTypeEnum.getByValue(nodeDto.getType()).getBranch()) {
// children = children.getChildren(); // children = children.getChildren();
//条件分支 // 条件分支
List<Node> branchs = nodeDto.getConditionNodes(); List<Node> branchs = nodeDto.getConditionNodes();
int ord = 1; int ord = 1;
int size = branchs.size(); int size = branchs.size();
for (Node branch : branchs) { for (Node branch : branchs) {
buildAllNodeOuterSequence(process, branch.getChildren(), nodeDto.getTailId()); buildAllNodeOuterSequence(process, branch.getChildren(), nodeDto.getTailId());
String expression = null; String expression = null;
if (nodeDto.getType() == NodeTypeEnum.EXCLUSIVE_GATEWAY.getValue().intValue() ) { if (nodeDto.getType() == NodeTypeEnum.EXCLUSIVE_GATEWAY.getValue().intValue()) {
if (ord == size) { if (ord == size) {
expression = NodeExpressionStrategyFactory.handleDefaultBranch(branchs, ord - 1); expression = NodeExpressionStrategyFactory.handleDefaultBranch(branchs, ord - 1);
} else if (nodeDto.getType() == NodeTypeEnum.EXCLUSIVE_GATEWAY.getValue().intValue() && ord > 1) { }
else if (nodeDto.getType() == NodeTypeEnum.EXCLUSIVE_GATEWAY.getValue().intValue() && ord > 1) {
expression = NodeExpressionStrategyFactory.handleDefaultBranch(branchs, ord - 1); expression = NodeExpressionStrategyFactory.handleDefaultBranch(branchs, ord - 1);
} else { }
else {
expression = NodeExpressionStrategyFactory.handle(branch); expression = NodeExpressionStrategyFactory.handle(branch);
} }
} }
// 添加连线
//添加连线
if (!NodeUtil.isNode(branch.getChildren())) { if (!NodeUtil.isNode(branch.getChildren())) {
//当前分支 没有其他节点了 所有就是网关和网关后面节点直接连线 // 当前分支 没有其他节点了 所有就是网关和网关后面节点直接连线
SequenceFlow sequenceFlow = buildSingleSequenceFlow(nodeDto.getId(), nodeDto.getTailId(), SequenceFlow sequenceFlow = buildSingleSequenceFlow(nodeDto.getId(), nodeDto.getTailId(),
expression, expression, StrUtil.format("{}->{}", nodeDto.getName(), nodeDto.getName()));
StrUtil.format("{}->{}", nodeDto.getName(), nodeDto.getName())
);
process.addFlowElement(sequenceFlow); process.addFlowElement(sequenceFlow);
} else { }
else {
SequenceFlow sequenceFlow = buildSingleSequenceFlow(nodeDto.getId(), branch.getChildren().getHeadId(), SequenceFlow sequenceFlow = buildSingleSequenceFlow(nodeDto.getId(),
expression, branch.getChildren().getHeadId(), expression,
StrUtil.format("{}->{}", nodeDto.getName(), branch.getChildren().getName()) StrUtil.format("{}->{}", nodeDto.getName(), branch.getChildren().getName()));
);
process.addFlowElement(sequenceFlow); process.addFlowElement(sequenceFlow);
} }
ord++; ord++;
} }
//分支结尾的合并分支节点-》下一个节点 // 分支结尾的合并分支节点-》下一个节点
if (children != null && StrUtil.isNotBlank(children.getHeadId()) && StrUtil.isNotBlank(nodeDto.getTailId())) { if (children != null && StrUtil.isNotBlank(children.getHeadId())
&& StrUtil.isNotBlank(nodeDto.getTailId())) {
SequenceFlow sequenceFlow = buildSingleSequenceFlow(nodeDto.getTailId(), children.getHeadId(), SequenceFlow sequenceFlow = buildSingleSequenceFlow(nodeDto.getTailId(), children.getHeadId(), "",
"", StrUtil.format("{}->{}", nodeDto.getName(), children.getName()));
StrUtil.format("{}->{}", nodeDto.getName(), children.getName())
);
process.addFlowElement(sequenceFlow); process.addFlowElement(sequenceFlow);
} else if (StrUtil.isAllNotBlank(nodeDto.getTailId(), nextId)) { }
SequenceFlow sequenceFlow = buildSingleSequenceFlow(nodeDto.getTailId(), nextId, else if (StrUtil.isAllNotBlank(nodeDto.getTailId(), nextId)) {
"", SequenceFlow sequenceFlow = buildSingleSequenceFlow(nodeDto.getTailId(), nextId, "",
StrUtil.format("{}->{}", nodeDto.getName(), nextId) StrUtil.format("{}->{}", nodeDto.getName(), nextId));
);
process.addFlowElement(sequenceFlow); process.addFlowElement(sequenceFlow);
} }
buildAllNodeOuterSequence(process, children, nextId); buildAllNodeOuterSequence(process, children, nextId);
}
} else { else {
//添加连线 // 添加连线
if (NodeUtil.isNode(children)) { if (NodeUtil.isNode(children)) {
List<SequenceFlow> sequenceFlowList = buildSequenceFlow(children, nodeDto, ""); List<SequenceFlow> sequenceFlowList = buildSequenceFlow(children, nodeDto, "");
for (SequenceFlow sequenceFlow : sequenceFlowList) { for (SequenceFlow sequenceFlow : sequenceFlowList) {
process.addFlowElement(sequenceFlow); process.addFlowElement(sequenceFlow);
} }
buildAllNodeOuterSequence(process, children, nextId); buildAllNodeOuterSequence(process, children, nextId);
} else if (nodeDto.getType() != NodeTypeEnum.END.getValue().intValue()) { }
SequenceFlow seq = buildSingleSequenceFlow(nodeDto.getTailId(), nextId, "", StrUtil.format("{}->{}", else if (nodeDto.getType() != NodeTypeEnum.END.getValue().intValue()) {
nodeDto.getName(), nextId)); SequenceFlow seq = buildSingleSequenceFlow(nodeDto.getTailId(), nextId, "",
StrUtil.format("{}->{}", nodeDto.getName(), nextId));
process.addFlowElement(seq); process.addFlowElement(seq);
@@ -266,11 +249,9 @@ public class ModelUtil {
} }
/** /**
* 构建节点 * 构建节点
* * @param node 前端传输节点
* @param node 前端传输节点
* @param flowId * @param flowId
* @return * @return
*/ */
@@ -280,13 +261,13 @@ public class ModelUtil {
return flowElementList; return flowElementList;
} }
//设置节点的连线头节点 // 设置节点的连线头节点
node.setHeadId(node.getId()); node.setHeadId(node.getId());
//设置节点的连线尾节点 // 设置节点的连线尾节点
node.setTailId(node.getId()); node.setTailId(node.getId());
node.setName(StrUtil.format("{}[{}]", node.getName(), RandomUtil.randomNumbers(5))); node.setName(StrUtil.format("{}[{}]", node.getName(), RandomUtil.randomNumbers(5)));
//存储节点数据 // 存储节点数据
RemoteFlowTaskService remoteFlowTaskService = SpringUtil.getBean(RemoteFlowTaskService.class); RemoteFlowTaskService remoteFlowTaskService = SpringUtil.getBean(RemoteFlowTaskService.class);
ProcessNodeDataDto processNodeDataDto = new ProcessNodeDataDto(); ProcessNodeDataDto processNodeDataDto = new ProcessNodeDataDto();
processNodeDataDto.setFlowId(flowId); processNodeDataDto.setFlowId(flowId);
@@ -294,32 +275,31 @@ public class ModelUtil {
processNodeDataDto.setData(JSONUtil.toJsonStr(node)); processNodeDataDto.setData(JSONUtil.toJsonStr(node));
remoteFlowTaskService.saveNodeOriData(processNodeDataDto); remoteFlowTaskService.saveNodeOriData(processNodeDataDto);
//开始 // 开始
if (node.getType() == NodeTypeEnum.ROOT.getValue().intValue()) { if (node.getType() == NodeTypeEnum.ROOT.getValue().intValue()) {
flowElementList.addAll(buildStartNode(node)); flowElementList.addAll(buildStartNode(node));
} }
//结束 // 结束
if (node.getType() == NodeTypeEnum.END.getValue().intValue()) { if (node.getType() == NodeTypeEnum.END.getValue().intValue()) {
flowElementList.add(buildEndNode(node, false)); flowElementList.add(buildEndNode(node, false));
} }
//审批 // 审批
if (node.getType() == NodeTypeEnum.APPROVAL.getValue().intValue()) { if (node.getType() == NodeTypeEnum.APPROVAL.getValue().intValue()) {
flowElementList.addAll(buildApproveNode(node)); flowElementList.addAll(buildApproveNode(node));
} }
//抄送 // 抄送
if (node.getType() == NodeTypeEnum.CC.getValue().intValue()) { if (node.getType() == NodeTypeEnum.CC.getValue().intValue()) {
flowElementList.add(buildCCNode(node)); flowElementList.add(buildCCNode(node));
} }
//条件分支 // 条件分支
if (node.getType() == NodeTypeEnum.EXCLUSIVE_GATEWAY.getValue().intValue()) { if (node.getType() == NodeTypeEnum.EXCLUSIVE_GATEWAY.getValue().intValue()) {
flowElementList.addAll(buildInclusiveGatewayNode(node)); flowElementList.addAll(buildInclusiveGatewayNode(node));
} }
//并行分支 // 并行分支
if (node.getType() == NodeTypeEnum.PARALLEL_GATEWAY.getValue().intValue()) { if (node.getType() == NodeTypeEnum.PARALLEL_GATEWAY.getValue().intValue()) {
flowElementList.addAll(buildParallelGatewayNode(node)); flowElementList.addAll(buildParallelGatewayNode(node));
} }
@@ -328,9 +308,7 @@ public class ModelUtil {
} }
/** /**
* 构建开始节点 * 构建开始节点 添加一个自动完成任务的用户任务节点
* 添加一个自动完成任务的用户任务节点
*
* @param node 前端传输节点 * @param node 前端传输节点
* @return * @return
*/ */
@@ -338,22 +316,17 @@ public class ModelUtil {
List<FlowElement> flowElementList = new ArrayList<>(); List<FlowElement> flowElementList = new ArrayList<>();
StartEvent startEvent = new StartEvent(); StartEvent startEvent = new StartEvent();
startEvent.setId(node.getId()); startEvent.setId(node.getId());
startEvent.setName(node.getName()); startEvent.setName(node.getName());
flowElementList.add(startEvent); flowElementList.add(startEvent);
return flowElementList; return flowElementList;
} }
/** /**
* 构建审批节点 * 构建审批节点
*
* @param node * @param node
* @return * @return
*/ */
@@ -361,21 +334,17 @@ public class ModelUtil {
List<FlowElement> flowElementList = new ArrayList<>(); List<FlowElement> flowElementList = new ArrayList<>();
node.setTailId(StrUtil.format("approve_service_task_{}", node.getId())); node.setTailId(StrUtil.format("approve_service_task_{}", node.getId()));
// 创建了任务执行监听器
//创建了任务执行监听器 // 先执行指派人 后创建
//先执行指派人 后创建 // https://tkjohn.github.io/flowable-userguide/#eventDispatcher
//https://tkjohn.github.io/flowable-userguide/#eventDispatcher
FlowableListener createListener = new FlowableListener(); FlowableListener createListener = new FlowableListener();
createListener.setImplementation(ApprovalCreateListener.class.getCanonicalName()); createListener.setImplementation(ApprovalCreateListener.class.getCanonicalName());
createListener.setImplementationType("class"); createListener.setImplementationType("class");
createListener.setEvent("create"); createListener.setEvent("create");
UserTask userTask = buildUserTask(node, createListener); UserTask userTask = buildUserTask(node, createListener);
flowElementList.add(userTask); flowElementList.add(userTask);
ServiceTask serviceTask = new ServiceTask(); ServiceTask serviceTask = new ServiceTask();
serviceTask.setId(StrUtil.format("approve_service_task_{}", node.getId())); serviceTask.setId(StrUtil.format("approve_service_task_{}", node.getId()));
serviceTask.setName(StrUtil.format("{}_服务任务", node.getName())); serviceTask.setName(StrUtil.format("{}_服务任务", node.getName()));
@@ -383,36 +352,31 @@ public class ModelUtil {
serviceTask.setImplementation(ApproveServiceTask.class.getCanonicalName()); serviceTask.setImplementation(ApproveServiceTask.class.getCanonicalName());
serviceTask.setAsynchronous(false); serviceTask.setAsynchronous(false);
flowElementList.add(serviceTask); flowElementList.add(serviceTask);
{ {
// 执行人处理
//执行人处理
String inputDataItem = "${multiInstanceHandler.resolveAssignee(execution)}"; String inputDataItem = "${multiInstanceHandler.resolveAssignee(execution)}";
// 串行
//串行
boolean isSequential = true; boolean isSequential = true;
Integer multipleMode = node.getMultipleMode(); Integer multipleMode = node.getMultipleMode();
//多人 // 多人
if ((multipleMode == ProcessInstanceConstant.MULTIPLE_MODE_AL_SAME)) { if ((multipleMode == ProcessInstanceConstant.MULTIPLE_MODE_AL_SAME)) {
//并行会签 // 并行会签
isSequential = false; isSequential = false;
} }
if ((multipleMode == ProcessInstanceConstant.MULTIPLE_MODE_ALL_SORT)) { if ((multipleMode == ProcessInstanceConstant.MULTIPLE_MODE_ALL_SORT)) {
//串行会签 // 串行会签
} }
if ((multipleMode == ProcessInstanceConstant.MULTIPLE_MODE_ONE)) { if ((multipleMode == ProcessInstanceConstant.MULTIPLE_MODE_ONE)) {
//或签 // 或签
isSequential = false; isSequential = false;
} }
@@ -431,11 +395,8 @@ public class ModelUtil {
return flowElementList; return flowElementList;
} }
/** /**
* 创建用户任务 * 创建用户任务
*
* @param node 前端传输节点 * @param node 前端传输节点
* @return * @return
*/ */
@@ -459,13 +420,11 @@ public class ModelUtil {
/** /**
* 构建简单的包容网关 * 构建简单的包容网关
*
* @param node * @param node
* @return * @return
*/ */
private static FlowElement buildSimpleExclusiveGatewayNode(Node node) { private static FlowElement buildSimpleExclusiveGatewayNode(Node node) {
ExclusiveGateway exclusiveGateway = new ExclusiveGateway(); ExclusiveGateway exclusiveGateway = new ExclusiveGateway();
exclusiveGateway.setId(node.getId()); exclusiveGateway.setId(node.getId());
exclusiveGateway.setName(node.getName()); exclusiveGateway.setName(node.getName());
@@ -474,10 +433,8 @@ public class ModelUtil {
} }
/** /**
* 构建并行网关 * 构建并行网关
*
* @param node * @param node
* @return * @return
*/ */
@@ -490,7 +447,7 @@ public class ModelUtil {
inclusiveGateway.setName(node.getName()); inclusiveGateway.setName(node.getName());
flowElementList.add(inclusiveGateway); flowElementList.add(inclusiveGateway);
//合并网关 // 合并网关
ParallelGateway parallelGateway = new ParallelGateway(); ParallelGateway parallelGateway = new ParallelGateway();
parallelGateway.setId(StrUtil.format("{}_merge_gateway", node.getId())); parallelGateway.setId(StrUtil.format("{}_merge_gateway", node.getId()));
parallelGateway.setName(StrUtil.format("{}_合并网关", node.getName())); parallelGateway.setName(StrUtil.format("{}_合并网关", node.getName()));
@@ -501,7 +458,6 @@ public class ModelUtil {
/** /**
* 构建包容网关 * 构建包容网关
*
* @param node * @param node
* @return * @return
*/ */
@@ -516,7 +472,7 @@ public class ModelUtil {
inclusiveGateway.setName(node.getName()); inclusiveGateway.setName(node.getName());
flowElementList.add(inclusiveGateway); flowElementList.add(inclusiveGateway);
//合并网关 // 合并网关
InclusiveGateway gateway = new InclusiveGateway(); InclusiveGateway gateway = new InclusiveGateway();
gateway.setId(StrUtil.format("{}_merge_gateway", node.getId())); gateway.setId(StrUtil.format("{}_merge_gateway", node.getId()));
gateway.setName(StrUtil.format("{}_合并网关", node.getName())); gateway.setName(StrUtil.format("{}_合并网关", node.getName()));
@@ -527,8 +483,7 @@ public class ModelUtil {
/** /**
* 构建结束节点 * 构建结束节点
* * @param node 前端传输节点
* @param node 前端传输节点
* @param terminateAll * @param terminateAll
* @return * @return
*/ */
@@ -537,7 +492,6 @@ public class ModelUtil {
endEvent.setId(node.getId()); endEvent.setId(node.getId());
endEvent.setName(node.getName()); endEvent.setName(node.getName());
List<EventDefinition> definitionList = new ArrayList<>(); List<EventDefinition> definitionList = new ArrayList<>();
TerminateEventDefinition definition = new TerminateEventDefinition(); TerminateEventDefinition definition = new TerminateEventDefinition();
definition.setTerminateAll(terminateAll); definition.setTerminateAll(terminateAll);
@@ -549,16 +503,14 @@ public class ModelUtil {
/** /**
* 创建连接线 * 创建连接线
* * @param node 子级节点
* @param node 子级节点
* @param parentNode 父级节点 * @param parentNode 父级节点
* @param expression * @param expression
* @return 所有连接线 * @return 所有连接线
*/ */
private static List<SequenceFlow> buildSequenceFlow(Node node, Node parentNode, String expression private static List<SequenceFlow> buildSequenceFlow(Node node, Node parentNode, String expression) {
) {
List<SequenceFlow> sequenceFlowList = new ArrayList<>(); List<SequenceFlow> sequenceFlowList = new ArrayList<>();
//没有子级了 // 没有子级了
if (!NodeUtil.isNode(node)) { if (!NodeUtil.isNode(node)) {
return sequenceFlowList; return sequenceFlowList;
} }
@@ -569,19 +521,15 @@ public class ModelUtil {
return sequenceFlowList; return sequenceFlowList;
} }
SequenceFlow sequenceFlow = buildSingleSequenceFlow(parentNode.getTailId(), node.getHeadId(), expression, SequenceFlow sequenceFlow = buildSingleSequenceFlow(parentNode.getTailId(), node.getHeadId(), expression,
StrUtil.format("{}->{}", parentNode.getName(), node.getName()) StrUtil.format("{}->{}", parentNode.getName(), node.getName()));
);
sequenceFlowList.add(sequenceFlow); sequenceFlowList.add(sequenceFlow);
return sequenceFlowList; return sequenceFlowList;
} }
/** /**
* 生成扩展数据 * 生成扩展数据
*
* @param key * @param key
* @param val * @param val
* @return * @return
@@ -596,7 +544,6 @@ public class ModelUtil {
/** /**
* 创建抄送节点 * 创建抄送节点
*
* @param node * @param node
* @return * @return
*/ */
@@ -612,9 +559,8 @@ public class ModelUtil {
ExtensionElement e = new ExtensionElement(); ExtensionElement e = new ExtensionElement();
{ {
e.setName("flowable:failedJobRetryTimeCycle"); e.setName("flowable:failedJobRetryTimeCycle");
//上面的例子会让作业执行器重试5次,并在每次重试前等待1分钟。 // 上面的例子会让作业执行器重试5次,并在每次重试前等待1分钟。
e.setElementText("R5/PT1M"); e.setElementText("R5/PT1M");
} }
@@ -623,57 +569,42 @@ public class ModelUtil {
return serviceTask; return serviceTask;
} }
/** /**
* 创建连接线 * 创建连接线
* * @param node 父级节点
* @param node 父级节点
* @param flowId * @param flowId
* @return 所有连接线 * @return 所有连接线
*/ */
private static List<SequenceFlow> buildInnerSequenceFlow(Node node, String flowId private static List<SequenceFlow> buildInnerSequenceFlow(Node node, String flowId) {
) {
List<SequenceFlow> sequenceFlowList = new ArrayList<>(); List<SequenceFlow> sequenceFlowList = new ArrayList<>();
if (!NodeUtil.isNode(node)) { if (!NodeUtil.isNode(node)) {
return sequenceFlowList; return sequenceFlowList;
} }
String nodeId = node.getId(); String nodeId = node.getId();
if (StrUtil.hasBlank(nodeId)) { if (StrUtil.hasBlank(nodeId)) {
return sequenceFlowList; return sequenceFlowList;
} }
if (node.getType() == NodeTypeEnum.APPROVAL.getValue().intValue()) { if (node.getType() == NodeTypeEnum.APPROVAL.getValue().intValue()) {
String gatewayId = StrUtil.format("approve_service_task_{}", nodeId); String gatewayId = StrUtil.format("approve_service_task_{}", nodeId);
{ {
SequenceFlow sequenceFlow = buildSingleSequenceFlow(nodeId, gatewayId, "${12==12}", null); SequenceFlow sequenceFlow = buildSingleSequenceFlow(nodeId, gatewayId, "${12==12}", null);
sequenceFlowList.add(sequenceFlow); sequenceFlowList.add(sequenceFlow);
} }
} }
return sequenceFlowList; return sequenceFlowList;
} }
/** /**
* 创建单个连接线 * 创建单个连接线
* * @param pId 父级id
* @param pId 父级id * @param childId 子级id
* @param childId 子级id
* @param expression 表达式 * @param expression 表达式
* @param name * @param name
* @return * @return
@@ -693,5 +624,4 @@ public class ModelUtil {
return sequenceFlow; return sequenceFlow;
} }
} }
@@ -506,7 +506,7 @@ public abstract class AbstractEngineConfiguration {
databaseTypeMappings.setProperty("DB2/PTX", DATABASE_TYPE_DB2); databaseTypeMappings.setProperty("DB2/PTX", DATABASE_TYPE_DB2);
databaseTypeMappings.setProperty("DB2/2", DATABASE_TYPE_DB2); databaseTypeMappings.setProperty("DB2/2", DATABASE_TYPE_DB2);
databaseTypeMappings.setProperty("DB2 UDB AS400", DATABASE_TYPE_DB2); databaseTypeMappings.setProperty("DB2 UDB AS400", DATABASE_TYPE_DB2);
databaseTypeMappings.setProperty("DM DBMS",DATABASE_TYPE_MYSQL);//扩展支持达梦数据 databaseTypeMappings.setProperty("DM DBMS", DATABASE_TYPE_MYSQL);// 扩展支持达梦数据
databaseTypeMappings.setProperty(PRODUCT_NAME_CRDB, DATABASE_TYPE_COCKROACHDB); databaseTypeMappings.setProperty(PRODUCT_NAME_CRDB, DATABASE_TYPE_COCKROACHDB);
return databaseTypeMappings; return databaseTypeMappings;
} }
+1 -1
View File
@@ -7,7 +7,7 @@
<parent> <parent>
<groupId>com.pig4cloud</groupId> <groupId>com.pig4cloud</groupId>
<artifactId>pigx-flow</artifactId> <artifactId>pigx-flow</artifactId>
<version>5.2.0-snapshot</version> <version>5.2.0</version>
</parent> </parent>
<artifactId>pigx-flow-engine</artifactId> <artifactId>pigx-flow-engine</artifactId>
@@ -7,7 +7,7 @@
<parent> <parent>
<groupId>com.pig4cloud</groupId> <groupId>com.pig4cloud</groupId>
<artifactId>pigx-flow-task</artifactId> <artifactId>pigx-flow-task</artifactId>
<version>5.2.0-snapshot</version> <version>5.2.0</version>
</parent> </parent>
<artifactId>pigx-flow-task-api</artifactId> <artifactId>pigx-flow-task-api</artifactId>
@@ -115,7 +115,6 @@ public interface RemoteFlowEngineService {
@PostMapping("/task/delegateTask") @PostMapping("/task/delegateTask")
R<String> delegateTask(@RequestBody TaskParamDto taskParamDto); R<String> delegateTask(@RequestBody TaskParamDto taskParamDto);
/** /**
* 查询任务 * 查询任务
* @param taskId 任务ID * @param taskId 任务ID
@@ -10,8 +10,8 @@ import lombok.Data;
@Data @Data
public class SelectValue { public class SelectValue {
private String key; private String key;
private String value; private String value;
} }
@@ -7,7 +7,7 @@
<parent> <parent>
<groupId>com.pig4cloud</groupId> <groupId>com.pig4cloud</groupId>
<artifactId>pigx-flow-task</artifactId> <artifactId>pigx-flow-task</artifactId>
<version>5.2.0-snapshot</version> <version>5.2.0</version>
</parent> </parent>
<artifactId>pigx-flow-task-biz</artifactId> <artifactId>pigx-flow-task-biz</artifactId>
@@ -52,7 +52,6 @@ public interface IProcessInstanceService {
*/ */
R queryMineCC(TaskQueryParamDto taskQueryParamDto); R queryMineCC(TaskQueryParamDto taskQueryParamDto);
/** /**
* 格式化流程显示 * 格式化流程显示
* @param nodeFormatParamVo * @param nodeFormatParamVo
@@ -289,7 +289,6 @@ public class ProcessInstanceServiceImpl implements IProcessInstanceService {
return R.ok(p); return R.ok(p);
} }
/** /**
* 格式化流程显示 * 格式化流程显示
* @param nodeFormatParamVo * @param nodeFormatParamVo
+1 -1
View File
@@ -7,7 +7,7 @@
<parent> <parent>
<groupId>com.pig4cloud</groupId> <groupId>com.pig4cloud</groupId>
<artifactId>pigx-flow</artifactId> <artifactId>pigx-flow</artifactId>
<version>5.2.0-snapshot</version> <version>5.2.0</version>
</parent> </parent>
<artifactId>pigx-flow-task</artifactId> <artifactId>pigx-flow-task</artifactId>
+1 -1
View File
@@ -24,7 +24,7 @@
<parent> <parent>
<groupId>com.pig4cloud</groupId> <groupId>com.pig4cloud</groupId>
<artifactId>pigx</artifactId> <artifactId>pigx</artifactId>
<version>5.2.0-snapshot</version> <version>5.2.0</version>
</parent> </parent>
<artifactId>pigx-flow</artifactId> <artifactId>pigx-flow</artifactId>
+1 -1
View File
@@ -24,7 +24,7 @@
<parent> <parent>
<groupId>com.pig4cloud</groupId> <groupId>com.pig4cloud</groupId>
<artifactId>pigx</artifactId> <artifactId>pigx</artifactId>
<version>5.2.0-snapshot</version> <version>5.2.0</version>
</parent> </parent>
<artifactId>pigx-gateway</artifactId> <artifactId>pigx-gateway</artifactId>
@@ -32,7 +32,7 @@ import java.util.stream.Collectors;
*/ */
@RequiredArgsConstructor @RequiredArgsConstructor
@Configuration(proxyBeanMethods = false) @Configuration(proxyBeanMethods = false)
@ConditionalOnProperty(value = "springdoc.api-docs.enabled",matchIfMissing = true) @ConditionalOnProperty(value = "springdoc.api-docs.enabled", matchIfMissing = true)
public class SpringDocConfiguration implements InitializingBean { public class SpringDocConfiguration implements InitializingBean {
private final SwaggerUiConfigProperties swaggerUiConfigProperties; private final SwaggerUiConfigProperties swaggerUiConfigProperties;
+1 -1
View File
@@ -18,7 +18,7 @@
<parent> <parent>
<groupId>com.pig4cloud</groupId> <groupId>com.pig4cloud</groupId>
<artifactId>pigx</artifactId> <artifactId>pigx</artifactId>
<version>5.2.0-snapshot</version> <version>5.2.0</version>
</parent> </parent>
<artifactId>pigx-register</artifactId> <artifactId>pigx-register</artifactId>
+1 -1
View File
@@ -24,7 +24,7 @@
<parent> <parent>
<groupId>com.pig4cloud</groupId> <groupId>com.pig4cloud</groupId>
<artifactId>pigx-upms</artifactId> <artifactId>pigx-upms</artifactId>
<version>5.2.0-snapshot</version> <version>5.2.0</version>
</parent> </parent>
<artifactId>pigx-upms-api</artifactId> <artifactId>pigx-upms-api</artifactId>
+1 -1
View File
@@ -24,7 +24,7 @@
<parent> <parent>
<groupId>com.pig4cloud</groupId> <groupId>com.pig4cloud</groupId>
<artifactId>pigx-upms</artifactId> <artifactId>pigx-upms</artifactId>
<version>5.2.0-snapshot</version> <version>5.2.0</version>
</parent> </parent>
<artifactId>pigx-upms-biz</artifactId> <artifactId>pigx-upms-biz</artifactId>
+1 -1
View File
@@ -24,7 +24,7 @@
<parent> <parent>
<groupId>com.pig4cloud</groupId> <groupId>com.pig4cloud</groupId>
<artifactId>pigx</artifactId> <artifactId>pigx</artifactId>
<version>5.2.0-snapshot</version> <version>5.2.0</version>
</parent> </parent>
<artifactId>pigx-upms</artifactId> <artifactId>pigx-upms</artifactId>
+1 -1
View File
@@ -6,7 +6,7 @@
<parent> <parent>
<groupId>com.pig4cloud</groupId> <groupId>com.pig4cloud</groupId>
<artifactId>pigx-visual</artifactId> <artifactId>pigx-visual</artifactId>
<version>5.2.0-snapshot</version> <version>5.2.0</version>
</parent> </parent>
<artifactId>pigx-codegen</artifactId> <artifactId>pigx-codegen</artifactId>
@@ -299,7 +299,8 @@ public class GeneratorServiceImpl implements GeneratorService {
// 按字段类型分组,使用 Map 存储不同类型的字段列表 // 按字段类型分组,使用 Map 存储不同类型的字段列表
Map<Boolean, List<GenTableColumnEntity>> typeMap = table.getFieldList() Map<Boolean, List<GenTableColumnEntity>> typeMap = table.getFieldList()
.stream() .stream()
.collect(Collectors.partitioningBy(columnEntity -> BooleanUtil.toBoolean(columnEntity.getPrimaryPk().toString()))); .collect(Collectors
.partitioningBy(columnEntity -> BooleanUtil.toBoolean(columnEntity.getPrimaryPk().toString())));
// 从分组后的 Map 中获取不同类型的字段列表 // 从分组后的 Map 中获取不同类型的字段列表
List<GenTableColumnEntity> primaryList = typeMap.get(true); List<GenTableColumnEntity> primaryList = typeMap.get(true);
+1 -1
View File
@@ -23,7 +23,7 @@
<parent> <parent>
<groupId>com.pig4cloud</groupId> <groupId>com.pig4cloud</groupId>
<artifactId>pigx-visual</artifactId> <artifactId>pigx-visual</artifactId>
<version>5.2.0-snapshot</version> <version>5.2.0</version>
</parent> </parent>
<artifactId>pigx-daemon-elastic-job</artifactId> <artifactId>pigx-daemon-elastic-job</artifactId>
+1 -1
View File
@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>com.pig4cloud</groupId> <groupId>com.pig4cloud</groupId>
<artifactId>pigx-visual</artifactId> <artifactId>pigx-visual</artifactId>
<version>5.2.0-snapshot</version> <version>5.2.0</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
+1 -1
View File
@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>com.pig4cloud</groupId> <groupId>com.pig4cloud</groupId>
<artifactId>pigx-visual</artifactId> <artifactId>pigx-visual</artifactId>
<version>5.2.0-snapshot</version> <version>5.2.0</version>
</parent> </parent>
<artifactId>pigx-jimu-platform</artifactId> <artifactId>pigx-jimu-platform</artifactId>
+1 -1
View File
@@ -24,7 +24,7 @@
<parent> <parent>
<groupId>com.pig4cloud</groupId> <groupId>com.pig4cloud</groupId>
<artifactId>pigx-visual</artifactId> <artifactId>pigx-visual</artifactId>
<version>5.2.0-snapshot</version> <version>5.2.0</version>
</parent> </parent>
<artifactId>pigx-monitor</artifactId> <artifactId>pigx-monitor</artifactId>
+1 -1
View File
@@ -6,7 +6,7 @@
<parent> <parent>
<groupId>com.pig4cloud</groupId> <groupId>com.pig4cloud</groupId>
<artifactId>pigx-visual</artifactId> <artifactId>pigx-visual</artifactId>
<version>5.2.0-snapshot</version> <version>5.2.0</version>
</parent> </parent>
<artifactId>pigx-mp-platform</artifactId> <artifactId>pigx-mp-platform</artifactId>
@@ -13,8 +13,11 @@ public class ImageBuilder extends AbstractBuilder {
@Override @Override
public WxMpXmlOutMessage build(String content, WxMpXmlMessage wxMessage, WxMpService service) { public WxMpXmlOutMessage build(String content, WxMpXmlMessage wxMessage, WxMpService service) {
WxMpXmlOutImageMessage m = WxMpXmlOutMessage.IMAGE().mediaId(content).fromUser(wxMessage.getToUser()) WxMpXmlOutImageMessage m = WxMpXmlOutMessage.IMAGE()
.toUser(wxMessage.getFromUser()).build(); .mediaId(content)
.fromUser(wxMessage.getToUser())
.toUser(wxMessage.getFromUser())
.build();
return m; return m;
} }
@@ -12,8 +12,11 @@ public class TextBuilder extends AbstractBuilder {
@Override @Override
public WxMpXmlOutMessage build(String content, WxMpXmlMessage wxMessage, WxMpService service) { public WxMpXmlOutMessage build(String content, WxMpXmlMessage wxMessage, WxMpService service) {
WxMpXmlOutTextMessage m = WxMpXmlOutMessage.TEXT().content(content).fromUser(wxMessage.getToUser()) WxMpXmlOutTextMessage m = WxMpXmlOutMessage.TEXT()
.toUser(wxMessage.getFromUser()).build(); .content(content)
.fromUser(wxMessage.getToUser())
.toUser(wxMessage.getFromUser())
.build();
return m; return m;
} }
@@ -127,36 +127,72 @@ public class WxMpInitConfigRunner {
newRouter.rule().handler(this.logHandler).next(); newRouter.rule().handler(this.logHandler).next();
// 接收客服会话管理事件 // 接收客服会话管理事件
newRouter.rule().async(false).msgType(XmlMsgType.EVENT) newRouter.rule()
.event(WxMpEventConstants.CustomerService.KF_CREATE_SESSION).handler(this.kfSessionHandler).end(); .async(false)
newRouter.rule().async(false).msgType(XmlMsgType.EVENT) .msgType(XmlMsgType.EVENT)
.event(WxMpEventConstants.CustomerService.KF_CLOSE_SESSION).handler(this.kfSessionHandler).end(); .event(WxMpEventConstants.CustomerService.KF_CREATE_SESSION)
newRouter.rule().async(false).msgType(XmlMsgType.EVENT) .handler(this.kfSessionHandler)
.event(WxMpEventConstants.CustomerService.KF_SWITCH_SESSION).handler(this.kfSessionHandler).end(); .end();
newRouter.rule()
.async(false)
.msgType(XmlMsgType.EVENT)
.event(WxMpEventConstants.CustomerService.KF_CLOSE_SESSION)
.handler(this.kfSessionHandler)
.end();
newRouter.rule()
.async(false)
.msgType(XmlMsgType.EVENT)
.event(WxMpEventConstants.CustomerService.KF_SWITCH_SESSION)
.handler(this.kfSessionHandler)
.end();
// 门店审核事件 // 门店审核事件
newRouter.rule().async(false).msgType(XmlMsgType.EVENT).event(WxMpEventConstants.POI_CHECK_NOTIFY) newRouter.rule()
.handler(this.storeCheckNotifyHandler).end(); .async(false)
.msgType(XmlMsgType.EVENT)
.event(WxMpEventConstants.POI_CHECK_NOTIFY)
.handler(this.storeCheckNotifyHandler)
.end();
// 自定义菜单事件 // 自定义菜单事件
newRouter.rule().async(false).msgType(XmlMsgType.EVENT).event(MenuButtonType.CLICK).handler(this.menuHandler) newRouter.rule()
.end(); .async(false)
.msgType(XmlMsgType.EVENT)
.event(MenuButtonType.CLICK)
.handler(this.menuHandler)
.end();
// 点击菜单连接事件 // 点击菜单连接事件
newRouter.rule().async(false).msgType(XmlMsgType.EVENT).event(MenuButtonType.VIEW).handler(this.nullHandler) newRouter.rule()
.end(); .async(false)
.msgType(XmlMsgType.EVENT)
.event(MenuButtonType.VIEW)
.handler(this.nullHandler)
.end();
// 关注事件 // 关注事件
newRouter.rule().async(false).msgType(XmlMsgType.EVENT).event(EventType.SUBSCRIBE) newRouter.rule()
.handler(this.subscribeHandler).end(); .async(false)
.msgType(XmlMsgType.EVENT)
.event(EventType.SUBSCRIBE)
.handler(this.subscribeHandler)
.end();
// 取消关注事件 // 取消关注事件
newRouter.rule().async(false).msgType(XmlMsgType.EVENT).event(EventType.UNSUBSCRIBE) newRouter.rule()
.handler(this.unsubscribeHandler).end(); .async(false)
.msgType(XmlMsgType.EVENT)
.event(EventType.UNSUBSCRIBE)
.handler(this.unsubscribeHandler)
.end();
// 上报地理位置事件 // 上报地理位置事件
newRouter.rule().async(false).msgType(XmlMsgType.EVENT).event(EventType.LOCATION).handler(this.locationHandler) newRouter.rule()
.end(); .async(false)
.msgType(XmlMsgType.EVENT)
.event(EventType.LOCATION)
.handler(this.locationHandler)
.end();
// 接收地理位置消息 // 接收地理位置消息
newRouter.rule().async(false).msgType(XmlMsgType.LOCATION).handler(this.locationHandler).end(); newRouter.rule().async(false).msgType(XmlMsgType.LOCATION).handler(this.locationHandler).end();
@@ -57,8 +57,8 @@ public class WxAccountController {
@GetMapping("/page") @GetMapping("/page")
public R getWxAccountPage(Page page, WxAccount wxAccount) { public R getWxAccountPage(Page page, WxAccount wxAccount) {
LambdaQueryWrapper<WxAccount> wrapper = Wrappers.<WxAccount>lambdaQuery() LambdaQueryWrapper<WxAccount> wrapper = Wrappers.<WxAccount>lambdaQuery()
.like(StrUtil.isNotBlank(wxAccount.getName()), WxAccount::getName, wxAccount.getName()) .like(StrUtil.isNotBlank(wxAccount.getName()), WxAccount::getName, wxAccount.getName())
.like(StrUtil.isNotBlank(wxAccount.getAccount()), WxAccount::getAccount, wxAccount.getAccount()); .like(StrUtil.isNotBlank(wxAccount.getAccount()), WxAccount::getAccount, wxAccount.getAccount());
return R.ok(wxAccountService.page(page, wrapper)); return R.ok(wxAccountService.page(page, wrapper));
} }
@@ -132,8 +132,8 @@ public class WxAccountController {
*/ */
@GetMapping("/list") @GetMapping("/list")
public R list(String name) { public R list(String name) {
LambdaQueryWrapper<WxAccount> wrapper = Wrappers.<WxAccount>lambdaQuery().like(StrUtil.isNotBlank(name), LambdaQueryWrapper<WxAccount> wrapper = Wrappers.<WxAccount>lambdaQuery()
WxAccount::getName, name); .like(StrUtil.isNotBlank(name), WxAccount::getName, name);
return R.ok(wxAccountService.list(wrapper)); return R.ok(wxAccountService.list(wrapper));
} }
@@ -37,9 +37,9 @@ public class WxAccountTagController {
@GetMapping("/page") @GetMapping("/page")
public R<Page<WxAccountTag>> getWxAccountTagPage(Page<WxAccountTag> page, WxAccountTag wxAccountTag) { public R<Page<WxAccountTag>> getWxAccountTagPage(Page<WxAccountTag> page, WxAccountTag wxAccountTag) {
LambdaQueryWrapper<WxAccountTag> wrapper = Wrappers.<WxAccountTag>lambdaQuery() LambdaQueryWrapper<WxAccountTag> wrapper = Wrappers.<WxAccountTag>lambdaQuery()
.like(StrUtil.isNotBlank(wxAccountTag.getTag()), WxAccountTag::getTag, wxAccountTag.getTag()) .like(StrUtil.isNotBlank(wxAccountTag.getTag()), WxAccountTag::getTag, wxAccountTag.getTag())
.eq(StrUtil.isNotBlank(wxAccountTag.getWxAccountAppid()), WxAccountTag::getWxAccountAppid, .eq(StrUtil.isNotBlank(wxAccountTag.getWxAccountAppid()), WxAccountTag::getWxAccountAppid,
wxAccountTag.getWxAccountAppid()); wxAccountTag.getWxAccountAppid());
return R.ok(wxAccountTagService.page(page, wrapper)); return R.ok(wxAccountTagService.page(page, wrapper));
} }
@@ -87,8 +87,8 @@ public class WxAutoReplyController {
*/ */
public void jude(WxAutoReply wxAutoReply) { public void jude(WxAutoReply wxAutoReply) {
if (ReplyTypeEnum.MSG.getType().equals(wxAutoReply.getType())) { if (ReplyTypeEnum.MSG.getType().equals(wxAutoReply.getType())) {
Wrapper<WxAutoReply> queryWrapper = Wrappers.<WxAutoReply>lambdaQuery().eq(WxAutoReply::getReqType, Wrapper<WxAutoReply> queryWrapper = Wrappers.<WxAutoReply>lambdaQuery()
wxAutoReply.getReqType()); .eq(WxAutoReply::getReqType, wxAutoReply.getReqType());
List<WxAutoReply> list = wxAutoReplyService.list(queryWrapper); List<WxAutoReply> list = wxAutoReplyService.list(queryWrapper);
if (wxAutoReply.getId() != null) { if (wxAutoReply.getId() != null) {
if (list != null && list.size() == 1) { if (list != null && list.size() == 1) {
@@ -103,8 +103,8 @@ public class WxAutoReplyController {
} }
if (ReplyTypeEnum.KEYWORD.getType().equals(wxAutoReply.getType())) { if (ReplyTypeEnum.KEYWORD.getType().equals(wxAutoReply.getType())) {
Wrapper<WxAutoReply> queryWrapper = Wrappers.<WxAutoReply>lambdaQuery() Wrapper<WxAutoReply> queryWrapper = Wrappers.<WxAutoReply>lambdaQuery()
.eq(WxAutoReply::getReqKey, wxAutoReply.getReqKey()) .eq(WxAutoReply::getReqKey, wxAutoReply.getReqKey())
.eq(WxAutoReply::getRepType, wxAutoReply.getRepMate()); .eq(WxAutoReply::getRepType, wxAutoReply.getRepMate());
List<WxAutoReply> list = wxAutoReplyService.list(queryWrapper); List<WxAutoReply> list = wxAutoReplyService.list(queryWrapper);
if (list != null && list.size() == 1) { if (list != null && list.size() == 1) {
if (!list.get(0).getId().equals(wxAutoReply.getId())) { if (!list.get(0).getId().equals(wxAutoReply.getId())) {
@@ -50,9 +50,9 @@ public class WxFansMsgController {
@GetMapping("/page") @GetMapping("/page")
public R getWxMsgPage(Page page, WxMsg msg) { public R getWxMsgPage(Page page, WxMsg msg) {
LambdaQueryWrapper<WxMsg> wrapper = Wrappers.<WxMsg>lambdaQuery() LambdaQueryWrapper<WxMsg> wrapper = Wrappers.<WxMsg>lambdaQuery()
.eq(StrUtil.isNotBlank(msg.getAppId()), WxMsg::getAppId, msg.getAppId()) .eq(StrUtil.isNotBlank(msg.getAppId()), WxMsg::getAppId, msg.getAppId())
.like(StrUtil.isNotBlank(msg.getNickName()), WxMsg::getNickName, msg.getNickName()) .like(StrUtil.isNotBlank(msg.getNickName()), WxMsg::getNickName, msg.getNickName())
.eq(StrUtil.isNotBlank(msg.getType()), WxMsg::getType, msg.getType()); .eq(StrUtil.isNotBlank(msg.getType()), WxMsg::getType, msg.getType());
return R.ok(wxMsgService.page(page, wrapper)); return R.ok(wxMsgService.page(page, wrapper));
} }
@@ -45,17 +45,18 @@ public class LocationHandler extends AbstractHandler {
wxMessage.getPrecision()); wxMessage.getPrecision());
// 发送关注消息 // 发送关注消息
List<WxAutoReply> listWxAutoReply = wxAutoReplyService List<WxAutoReply> listWxAutoReply = wxAutoReplyService.list(Wrappers.<WxAutoReply>query()
.list(Wrappers.<WxAutoReply>query().lambda().eq(WxAutoReply::getType, ReplyTypeEnum.MSG.getType()) .lambda()
.eq(WxAutoReply::getAppId, WxMpContextHolder.getAppId()) .eq(WxAutoReply::getType, ReplyTypeEnum.MSG.getType())
.eq(WxAutoReply::getReqType, wxMessage.getMsgType())); .eq(WxAutoReply::getAppId, WxMpContextHolder.getAppId())
.eq(WxAutoReply::getReqType, wxMessage.getMsgType()));
// 查询公众号 基本信息 // 查询公众号 基本信息
WxAccount wxAccount = wxAccountMapper WxAccount wxAccount = wxAccountMapper
.selectOne(Wrappers.<WxAccount>lambdaQuery().eq(WxAccount::getAccount, wxMessage.getToUser())); .selectOne(Wrappers.<WxAccount>lambdaQuery().eq(WxAccount::getAccount, wxMessage.getToUser()));
// 查询粉丝基本信息 // 查询粉丝基本信息
WxAccountFans fans = wxAccountFansMapper WxAccountFans fans = wxAccountFansMapper
.selectOne(Wrappers.<WxAccountFans>lambdaQuery().eq(WxAccountFans::getOpenid, wxMessage.getFromUser())); .selectOne(Wrappers.<WxAccountFans>lambdaQuery().eq(WxAccountFans::getOpenid, wxMessage.getFromUser()));
return MsgHandler.getWxMpXmlOutMessage(wxMessage, listWxAutoReply, fans, msgMapper, wxAccount); return MsgHandler.getWxMpXmlOutMessage(wxMessage, listWxAutoReply, fans, msgMapper, wxAccount);
} }
@@ -44,10 +44,10 @@ public class LogHandler extends AbstractHandler {
log.debug("接收到请求消息,内容:{}", wxMessage.getContent()); log.debug("接收到请求消息,内容:{}", wxMessage.getContent());
WxAccount wxAccount = accountMapper WxAccount wxAccount = accountMapper
.selectOne(Wrappers.<WxAccount>lambdaQuery().eq(WxAccount::getAccount, wxMessage.getToUser())); .selectOne(Wrappers.<WxAccount>lambdaQuery().eq(WxAccount::getAccount, wxMessage.getToUser()));
WxAccountFans fans = fansMapper WxAccountFans fans = fansMapper
.selectOne(Wrappers.<WxAccountFans>lambdaQuery().eq(WxAccountFans::getOpenid, wxMessage.getFromUser())); .selectOne(Wrappers.<WxAccountFans>lambdaQuery().eq(WxAccountFans::getOpenid, wxMessage.getFromUser()));
if (fans == null) { if (fans == null) {
return null; return null;
@@ -47,10 +47,11 @@ public class MenuHandler extends AbstractHandler {
*/ */
public WxMpXmlOutMessage getWxMpXmlOutMessage(WxMpXmlMessage wxMessage) { public WxMpXmlOutMessage getWxMpXmlOutMessage(WxMpXmlMessage wxMessage) {
WxMpMenu wxMpMenu = wxMenuMapper.selectOne( WxMpMenu wxMpMenu = wxMenuMapper
Wrappers.<WxMpMenu>lambdaQuery().eq(WxMpMenu::getWxAccountAppid, WxMpContextHolder.getAppId())); .selectOne(Wrappers.<WxMpMenu>lambdaQuery().eq(WxMpMenu::getWxAccountAppid, WxMpContextHolder.getAppId()));
List<JSONObject> buttons = JSONUtil.parseObj(wxMpMenu.getMenu()).getJSONArray("button") List<JSONObject> buttons = JSONUtil.parseObj(wxMpMenu.getMenu())
.toList(JSONObject.class); .getJSONArray("button")
.toList(JSONObject.class);
String eventKey = wxMessage.getEventKey(); String eventKey = wxMessage.getEventKey();
// 获取子集 // 获取子集
@@ -80,23 +81,33 @@ public class MenuHandler extends AbstractHandler {
String repMediaId = button.getStr("repMediaId"); String repMediaId = button.getStr("repMediaId");
String repDesc = button.getStr("repDesc"); String repDesc = button.getStr("repDesc");
if (WxConsts.KefuMsgType.TEXT.equals(repType)) { if (WxConsts.KefuMsgType.TEXT.equals(repType)) {
wxMpXmlOutMessage = new TextBuilder().fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser()) wxMpXmlOutMessage = new TextBuilder().fromUser(wxMessage.getToUser())
.content(repContent).build(); .toUser(wxMessage.getFromUser())
.content(repContent)
.build();
} }
if (WxConsts.KefuMsgType.IMAGE.equals(repType)) { if (WxConsts.KefuMsgType.IMAGE.equals(repType)) {
wxMpXmlOutMessage = new ImageBuilder().fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser()) wxMpXmlOutMessage = new ImageBuilder().fromUser(wxMessage.getToUser())
.mediaId(repMediaId).build(); .toUser(wxMessage.getFromUser())
.mediaId(repMediaId)
.build();
} }
if (WxConsts.KefuMsgType.VOICE.equals(repType)) { if (WxConsts.KefuMsgType.VOICE.equals(repType)) {
wxMpXmlOutMessage = new VoiceBuilder().fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser()) wxMpXmlOutMessage = new VoiceBuilder().fromUser(wxMessage.getToUser())
.mediaId(repMediaId).build(); .toUser(wxMessage.getFromUser())
.mediaId(repMediaId)
.build();
} }
if (WxConsts.KefuMsgType.VIDEO.equals(repType)) { if (WxConsts.KefuMsgType.VIDEO.equals(repType)) {
wxMpXmlOutMessage = new VideoBuilder().fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser()) wxMpXmlOutMessage = new VideoBuilder().fromUser(wxMessage.getToUser())
.mediaId(repMediaId).title(repName).description(repDesc).build(); .toUser(wxMessage.getFromUser())
.mediaId(repMediaId)
.title(repName)
.description(repDesc)
.build();
} }
if (WxConsts.KefuMsgType.MUSIC.equals(repType)) { if (WxConsts.KefuMsgType.MUSIC.equals(repType)) {
@@ -104,17 +115,23 @@ public class MenuHandler extends AbstractHandler {
String repUrl = button.getStr("repUrl"); String repUrl = button.getStr("repUrl");
String repHqUrl = button.getStr("repHqUrl"); String repHqUrl = button.getStr("repHqUrl");
wxMpXmlOutMessage = new MusicBuilder().fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser()) wxMpXmlOutMessage = new MusicBuilder().fromUser(wxMessage.getToUser())
.thumbMediaId(repThumbMediaId).title(repName).description(repDesc).musicUrl(repUrl) .toUser(wxMessage.getFromUser())
.hqMusicUrl(repHqUrl).build(); .thumbMediaId(repThumbMediaId)
.title(repName)
.description(repDesc)
.musicUrl(repUrl)
.hqMusicUrl(repHqUrl)
.build();
} }
if (WxConsts.KefuMsgType.NEWS.equals(repType)) { if (WxConsts.KefuMsgType.NEWS.equals(repType)) {
String content = button.getStr("content"); String content = button.getStr("content");
List<WxMpXmlOutNewsMessage.Item> list = new ArrayList<>(); List<WxMpXmlOutNewsMessage.Item> list = new ArrayList<>();
List<JSONObject> articles = JSONUtil.parseObj(content).getJSONArray("articles") List<JSONObject> articles = JSONUtil.parseObj(content)
.toList(JSONObject.class); .getJSONArray("articles")
.toList(JSONObject.class);
WxMpXmlOutNewsMessage.Item t; WxMpXmlOutNewsMessage.Item t;
for (JSONObject jsonObject : articles) { for (JSONObject jsonObject : articles) {
t = new WxMpXmlOutNewsMessage.Item(); t = new WxMpXmlOutNewsMessage.Item();
@@ -124,8 +141,10 @@ public class MenuHandler extends AbstractHandler {
t.setUrl(jsonObject.getStr("url")); t.setUrl(jsonObject.getStr("url"));
list.add(t); list.add(t);
} }
wxMpXmlOutMessage = new NewsBuilder().fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser()) wxMpXmlOutMessage = new NewsBuilder().fromUser(wxMessage.getToUser())
.articles(list).build(); .toUser(wxMessage.getFromUser())
.articles(list)
.build();
} }
return wxMpXmlOutMessage; return wxMpXmlOutMessage;
} }
@@ -53,19 +53,20 @@ public class MsgHandler extends AbstractHandler {
// 组装回复消息 // 组装回复消息
if (!wxMessage.getMsgType().equals(XmlMsgType.EVENT)) { if (!wxMessage.getMsgType().equals(XmlMsgType.EVENT)) {
WxMpXmlOutMessage rs; WxMpXmlOutMessage rs;
WxAccountFans fans = wxAccountFansMapper.selectOne( WxAccountFans fans = wxAccountFansMapper
Wrappers.<WxAccountFans>lambdaQuery().eq(WxAccountFans::getOpenid, wxMessage.getFromUser())); .selectOne(Wrappers.<WxAccountFans>lambdaQuery().eq(WxAccountFans::getOpenid, wxMessage.getFromUser()));
// 查询公众号 基本信息 // 查询公众号 基本信息
WxAccount wxAccount = wxAccountMapper WxAccount wxAccount = wxAccountMapper
.selectOne(Wrappers.<WxAccount>lambdaQuery().eq(WxAccount::getAccount, wxMessage.getToUser())); .selectOne(Wrappers.<WxAccount>lambdaQuery().eq(WxAccount::getAccount, wxMessage.getToUser()));
// 1、先处理是否有文本关键字回复 // 1、先处理是否有文本关键字回复
if (WxConsts.KefuMsgType.TEXT.equals(wxMessage.getMsgType())) { if (WxConsts.KefuMsgType.TEXT.equals(wxMessage.getMsgType())) {
// 先全匹配 // 先全匹配
List<WxAutoReply> listWxAutoReply = wxAutoReplyService.list( List<WxAutoReply> listWxAutoReply = wxAutoReplyService.list(Wrappers.<WxAutoReply>query()
Wrappers.<WxAutoReply>query().lambda().eq(WxAutoReply::getType, ReplyTypeEnum.KEYWORD.getType()) .lambda()
.eq(WxAutoReply::getRepMate, ReplyMateEnum.ALL.getType()) .eq(WxAutoReply::getType, ReplyTypeEnum.KEYWORD.getType())
.eq(WxAutoReply::getAppId, WxMpContextHolder.getAppId()) .eq(WxAutoReply::getRepMate, ReplyMateEnum.ALL.getType())
.eq(WxAutoReply::getReqKey, wxMessage.getContent())); .eq(WxAutoReply::getAppId, WxMpContextHolder.getAppId())
.eq(WxAutoReply::getReqKey, wxMessage.getContent()));
if (listWxAutoReply != null && listWxAutoReply.size() > 0) { if (listWxAutoReply != null && listWxAutoReply.size() > 0) {
rs = getWxMpXmlOutMessage(wxMessage, listWxAutoReply, fans, wxMsgMapper, wxAccount); rs = getWxMpXmlOutMessage(wxMessage, listWxAutoReply, fans, wxMsgMapper, wxAccount);
if (rs != null) { if (rs != null) {
@@ -73,11 +74,12 @@ public class MsgHandler extends AbstractHandler {
} }
} }
// 再半匹配 // 再半匹配
listWxAutoReply = wxAutoReplyService.list( listWxAutoReply = wxAutoReplyService.list(Wrappers.<WxAutoReply>query()
Wrappers.<WxAutoReply>query().lambda().eq(WxAutoReply::getType, ReplyTypeEnum.KEYWORD.getType()) .lambda()
.eq(WxAutoReply::getAppId, WxMpContextHolder.getAppId()) .eq(WxAutoReply::getType, ReplyTypeEnum.KEYWORD.getType())
.eq(WxAutoReply::getRepMate, ReplyMateEnum.LIKE.getType()) .eq(WxAutoReply::getAppId, WxMpContextHolder.getAppId())
.like(WxAutoReply::getReqKey, wxMessage.getContent())); .eq(WxAutoReply::getRepMate, ReplyMateEnum.LIKE.getType())
.like(WxAutoReply::getReqKey, wxMessage.getContent()));
if (listWxAutoReply != null && listWxAutoReply.size() > 0) { if (listWxAutoReply != null && listWxAutoReply.size() > 0) {
rs = getWxMpXmlOutMessage(wxMessage, listWxAutoReply, fans, wxMsgMapper, wxAccount); rs = getWxMpXmlOutMessage(wxMessage, listWxAutoReply, fans, wxMsgMapper, wxAccount);
if (rs != null) { if (rs != null) {
@@ -86,10 +88,11 @@ public class MsgHandler extends AbstractHandler {
} }
} }
// 2、再处理消息回复 // 2、再处理消息回复
List<WxAutoReply> listWxAutoReply = wxAutoReplyService List<WxAutoReply> listWxAutoReply = wxAutoReplyService.list(Wrappers.<WxAutoReply>query()
.list(Wrappers.<WxAutoReply>query().lambda().eq(WxAutoReply::getAppId, WxMpContextHolder.getAppId()) .lambda()
.eq(WxAutoReply::getType, ReplyTypeEnum.MSG.getType()) .eq(WxAutoReply::getAppId, WxMpContextHolder.getAppId())
.eq(WxAutoReply::getReqType, wxMessage.getMsgType())); .eq(WxAutoReply::getType, ReplyTypeEnum.MSG.getType())
.eq(WxAutoReply::getReqType, wxMessage.getMsgType()));
rs = getWxMpXmlOutMessage(wxMessage, listWxAutoReply, fans, wxMsgMapper, wxAccount); rs = getWxMpXmlOutMessage(wxMessage, listWxAutoReply, fans, wxMsgMapper, wxAccount);
return rs; return rs;
} }
@@ -126,8 +129,10 @@ public class MsgHandler extends AbstractHandler {
// 文本 // 文本
if (WxConsts.KefuMsgType.TEXT.equals(wxAutoReply.getRepType())) { if (WxConsts.KefuMsgType.TEXT.equals(wxAutoReply.getRepType())) {
wxMsg.setRepContent(wxAutoReply.getRepContent()); wxMsg.setRepContent(wxAutoReply.getRepContent());
wxMpXmlOutMessage = new TextBuilder().fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser()) wxMpXmlOutMessage = new TextBuilder().fromUser(wxMessage.getToUser())
.content(wxAutoReply.getRepContent()).build(); .toUser(wxMessage.getFromUser())
.content(wxAutoReply.getRepContent())
.build();
} }
// 图片 // 图片
@@ -135,24 +140,31 @@ public class MsgHandler extends AbstractHandler {
wxMsg.setRepName(wxAutoReply.getRepName()); wxMsg.setRepName(wxAutoReply.getRepName());
wxMsg.setRepUrl(wxAutoReply.getRepUrl()); wxMsg.setRepUrl(wxAutoReply.getRepUrl());
wxMsg.setRepMediaId(wxAutoReply.getRepMediaId()); wxMsg.setRepMediaId(wxAutoReply.getRepMediaId());
wxMpXmlOutMessage = new ImageBuilder().fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser()) wxMpXmlOutMessage = new ImageBuilder().fromUser(wxMessage.getToUser())
.mediaId(wxAutoReply.getRepMediaId()).build(); .toUser(wxMessage.getFromUser())
.mediaId(wxAutoReply.getRepMediaId())
.build();
} }
if (WxConsts.KefuMsgType.VOICE.equals(wxAutoReply.getRepType())) { if (WxConsts.KefuMsgType.VOICE.equals(wxAutoReply.getRepType())) {
wxMsg.setRepName(wxAutoReply.getRepName()); wxMsg.setRepName(wxAutoReply.getRepName());
wxMsg.setRepUrl(wxAutoReply.getRepUrl()); wxMsg.setRepUrl(wxAutoReply.getRepUrl());
wxMsg.setRepMediaId(wxAutoReply.getRepMediaId()); wxMsg.setRepMediaId(wxAutoReply.getRepMediaId());
wxMpXmlOutMessage = new VoiceBuilder().fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser()) wxMpXmlOutMessage = new VoiceBuilder().fromUser(wxMessage.getToUser())
.mediaId(wxAutoReply.getRepMediaId()).build(); .toUser(wxMessage.getFromUser())
.mediaId(wxAutoReply.getRepMediaId())
.build();
} }
if (WxConsts.KefuMsgType.VIDEO.equals(wxAutoReply.getRepType())) { if (WxConsts.KefuMsgType.VIDEO.equals(wxAutoReply.getRepType())) {
wxMsg.setRepName(wxAutoReply.getRepName()); wxMsg.setRepName(wxAutoReply.getRepName());
wxMsg.setRepDesc(wxAutoReply.getRepDesc()); wxMsg.setRepDesc(wxAutoReply.getRepDesc());
wxMsg.setRepUrl(wxAutoReply.getRepUrl()); wxMsg.setRepUrl(wxAutoReply.getRepUrl());
wxMsg.setRepMediaId(wxAutoReply.getRepMediaId()); wxMsg.setRepMediaId(wxAutoReply.getRepMediaId());
wxMpXmlOutMessage = new VideoBuilder().fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser()) wxMpXmlOutMessage = new VideoBuilder().fromUser(wxMessage.getToUser())
.mediaId(wxAutoReply.getRepMediaId()).title(wxAutoReply.getRepName()) .toUser(wxMessage.getFromUser())
.description(wxAutoReply.getRepDesc()).build(); .mediaId(wxAutoReply.getRepMediaId())
.title(wxAutoReply.getRepName())
.description(wxAutoReply.getRepDesc())
.build();
} }
if (WxConsts.KefuMsgType.MUSIC.equals(wxAutoReply.getRepType())) { if (WxConsts.KefuMsgType.MUSIC.equals(wxAutoReply.getRepType())) {
wxMsg.setRepName(wxAutoReply.getRepName()); wxMsg.setRepName(wxAutoReply.getRepName());
@@ -161,10 +173,14 @@ public class MsgHandler extends AbstractHandler {
wxMsg.setRepHqUrl(wxAutoReply.getRepHqUrl()); wxMsg.setRepHqUrl(wxAutoReply.getRepHqUrl());
wxMsg.setRepThumbMediaId(wxAutoReply.getRepThumbMediaId()); wxMsg.setRepThumbMediaId(wxAutoReply.getRepThumbMediaId());
wxMsg.setRepThumbUrl(wxAutoReply.getRepThumbUrl()); wxMsg.setRepThumbUrl(wxAutoReply.getRepThumbUrl());
wxMpXmlOutMessage = new MusicBuilder().fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser()) wxMpXmlOutMessage = new MusicBuilder().fromUser(wxMessage.getToUser())
.thumbMediaId(wxAutoReply.getRepThumbMediaId()).title(wxAutoReply.getRepName()) .toUser(wxMessage.getFromUser())
.description(wxAutoReply.getRepDesc()).musicUrl(wxAutoReply.getRepUrl()) .thumbMediaId(wxAutoReply.getRepThumbMediaId())
.hqMusicUrl(wxAutoReply.getRepHqUrl()).build(); .title(wxAutoReply.getRepName())
.description(wxAutoReply.getRepDesc())
.musicUrl(wxAutoReply.getRepUrl())
.hqMusicUrl(wxAutoReply.getRepHqUrl())
.build();
} }
if (WxConsts.KefuMsgType.NEWS.equals(wxAutoReply.getRepType())) { if (WxConsts.KefuMsgType.NEWS.equals(wxAutoReply.getRepType())) {
List<WxMpXmlOutNewsMessage.Item> list = new ArrayList<>(); List<WxMpXmlOutNewsMessage.Item> list = new ArrayList<>();
@@ -183,8 +199,10 @@ public class MsgHandler extends AbstractHandler {
wxMsg.setRepUrl(wxAutoReply.getRepUrl()); wxMsg.setRepUrl(wxAutoReply.getRepUrl());
wxMsg.setRepMediaId(wxAutoReply.getRepMediaId()); wxMsg.setRepMediaId(wxAutoReply.getRepMediaId());
wxMsg.setContent(wxAutoReply.getContent()); wxMsg.setContent(wxAutoReply.getContent());
wxMpXmlOutMessage = new NewsBuilder().fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser()) wxMpXmlOutMessage = new NewsBuilder().fromUser(wxMessage.getToUser())
.articles(list).build(); .toUser(wxMessage.getFromUser())
.articles(list)
.build();
} }
wxMsgMapper.insert(wxMsg); wxMsgMapper.insert(wxMsg);
} }
@@ -66,7 +66,7 @@ public class SubscribeHandler extends AbstractHandler {
wxAccountFans.setOpenid(wxMpUser.getOpenId()); wxAccountFans.setOpenid(wxMpUser.getOpenId());
wxAccountFans.setSubscribeStatus(String.valueOf(BooleanUtil.toInt(wxMpUser.getSubscribe()))); wxAccountFans.setSubscribeStatus(String.valueOf(BooleanUtil.toInt(wxMpUser.getSubscribe())));
wxAccountFans.setSubscribeTime(LocalDateTime wxAccountFans.setSubscribeTime(LocalDateTime
.ofInstant(Instant.ofEpochMilli(wxMpUser.getSubscribeTime() * 1000L), ZoneId.systemDefault())); .ofInstant(Instant.ofEpochMilli(wxMpUser.getSubscribeTime() * 1000L), ZoneId.systemDefault()));
// 随机生成一个昵称,方便平台内部使用 // 随机生成一个昵称,方便平台内部使用
String generatedName = ChineseNameGenerator.getInstance().generate(); String generatedName = ChineseNameGenerator.getInstance().generate();
@@ -77,7 +77,7 @@ public class SubscribeHandler extends AbstractHandler {
wxAccountFans.setTagIds(wxAccountFans.getTagIds()); wxAccountFans.setTagIds(wxAccountFans.getTagIds());
WxAccount wxAccount = wxAccountMapper WxAccount wxAccount = wxAccountMapper
.selectOne(Wrappers.<WxAccount>lambdaQuery().eq(WxAccount::getAppid, WxMpContextHolder.getAppId())); .selectOne(Wrappers.<WxAccount>lambdaQuery().eq(WxAccount::getAppid, WxMpContextHolder.getAppId()));
wxAccountFans.setWxAccountId(wxAccount.getId()); wxAccountFans.setWxAccountId(wxAccount.getId());
wxAccountFans.setWxAccountAppid(wxAccount.getAppid()); wxAccountFans.setWxAccountAppid(wxAccount.getAppid());
wxAccountFans.setWxAccountName(wxAccount.getName()); wxAccountFans.setWxAccountName(wxAccount.getName());
@@ -97,12 +97,13 @@ public class SubscribeHandler extends AbstractHandler {
*/ */
private WxMpXmlOutMessage handleSpecial(WxMpXmlMessage wxMessage, WxAccountFans fans) { private WxMpXmlOutMessage handleSpecial(WxMpXmlMessage wxMessage, WxAccountFans fans) {
// 发送关注消息 // 发送关注消息
List<WxAutoReply> listWxAutoReply = wxAutoReplyService List<WxAutoReply> listWxAutoReply = wxAutoReplyService.list(Wrappers.<WxAutoReply>query()
.list(Wrappers.<WxAutoReply>query().lambda().eq(WxAutoReply::getType, ReplyTypeEnum.ATTENTION.getType()) .lambda()
.eq(WxAutoReply::getAppId, WxMpContextHolder.getAppId())); .eq(WxAutoReply::getType, ReplyTypeEnum.ATTENTION.getType())
.eq(WxAutoReply::getAppId, WxMpContextHolder.getAppId()));
// 查询公众号 基本信息 // 查询公众号 基本信息
WxAccount wxAccount = wxAccountMapper WxAccount wxAccount = wxAccountMapper
.selectOne(Wrappers.<WxAccount>lambdaQuery().eq(WxAccount::getAccount, wxMessage.getToUser())); .selectOne(Wrappers.<WxAccount>lambdaQuery().eq(WxAccount::getAccount, wxMessage.getToUser()));
WxMpXmlOutMessage wxMpXmlOutMessage = MsgHandler.getWxMpXmlOutMessage(wxMessage, listWxAutoReply, fans, WxMpXmlOutMessage wxMpXmlOutMessage = MsgHandler.getWxMpXmlOutMessage(wxMessage, listWxAutoReply, fans,
msgMapper, wxAccount); msgMapper, wxAccount);
return wxMpXmlOutMessage; return wxMpXmlOutMessage;
@@ -91,10 +91,10 @@ public class WxAccountFansServiceImpl extends ServiceImpl<WxAccountFansMapper, W
// 翻页查询粉丝 // 翻页查询粉丝
LambdaQueryWrapper<WxAccountFans> wrapper = Wrappers.<WxAccountFans>lambdaQuery() LambdaQueryWrapper<WxAccountFans> wrapper = Wrappers.<WxAccountFans>lambdaQuery()
.eq(StrUtil.isNotBlank(wxAccountFans.getWxAccountAppid()), WxAccountFans::getWxAccountAppid, .eq(StrUtil.isNotBlank(wxAccountFans.getWxAccountAppid()), WxAccountFans::getWxAccountAppid,
wxAccountFans.getWxAccountAppid()) wxAccountFans.getWxAccountAppid())
.like(StrUtil.isNotBlank(wxAccountFans.getNickname()), WxAccountFans::getNickname, .like(StrUtil.isNotBlank(wxAccountFans.getNickname()), WxAccountFans::getNickname,
wxAccountFans.getNickname()); wxAccountFans.getNickname());
IPage<WxAccountFans> fansPage = baseMapper.selectPage(page, wrapper); IPage<WxAccountFans> fansPage = baseMapper.selectPage(page, wrapper);
@@ -104,9 +104,9 @@ public class WxAccountFansServiceImpl extends ServiceImpl<WxAccountFansMapper, W
// 赋值 TAG_NAME // 赋值 TAG_NAME
if (ArrayUtil.isNotEmpty(fans.getTagIds())) { if (ArrayUtil.isNotEmpty(fans.getTagIds())) {
List<WxAccountTag> tagList = wxAccountTags.stream() List<WxAccountTag> tagList = wxAccountTags.stream()
.filter(tag -> tag.getWxAccountAppid().endsWith(fans.getWxAccountAppid()) // .filter(tag -> tag.getWxAccountAppid().endsWith(fans.getWxAccountAppid()) //
&& ArrayUtil.contains(fans.getTagIds(), tag.getTagId())) && ArrayUtil.contains(fans.getTagIds(), tag.getTagId()))
.collect(Collectors.toList()); .collect(Collectors.toList());
vo.setTagList(tagList); vo.setTagList(tagList);
} }
return vo; return vo;
@@ -198,7 +198,7 @@ public class WxAccountFansServiceImpl extends ServiceImpl<WxAccountFansMapper, W
@Override @Override
public Boolean syncAccountFans(String appId) { public Boolean syncAccountFans(String appId) {
WxAccount wxAccount = wxAccountMapper WxAccount wxAccount = wxAccountMapper
.selectOne(Wrappers.<WxAccount>query().lambda().eq(WxAccount::getAppid, appId)); .selectOne(Wrappers.<WxAccount>query().lambda().eq(WxAccount::getAppid, appId));
// 获取操作微信接口类 // 获取操作微信接口类
WxMpService wxMpService = WxMpInitConfigRunner.getMpServices().get(appId); WxMpService wxMpService = WxMpInitConfigRunner.getMpServices().get(appId);
@@ -222,8 +222,10 @@ public class WxAccountFansServiceImpl extends ServiceImpl<WxAccountFansMapper, W
try { try {
WxMpUserList wxMpUserList = wxMpUserService.userList(nextOpenid); WxMpUserList wxMpUserList = wxMpUserService.userList(nextOpenid);
// openId 分组 每组 100个 openid // openId 分组 每组 100个 openid
List<List<String>> openIdsList = CollUtil.split(wxMpUserList.getOpenids(), SIZE).stream() List<List<String>> openIdsList = CollUtil.split(wxMpUserList.getOpenids(), SIZE)
.filter(CollUtil::isNotEmpty).collect(Collectors.toList()); .stream()
.filter(CollUtil::isNotEmpty)
.collect(Collectors.toList());
// 处理每个分组. 调用查询用户信息 // 处理每个分组. 调用查询用户信息
for (List<String> openIdList : openIdsList) { for (List<String> openIdList : openIdsList) {
log.info("开始批量获取用户信息 {}", openIdList); log.info("开始批量获取用户信息 {}", openIdList);
@@ -262,7 +264,7 @@ public class WxAccountFansServiceImpl extends ServiceImpl<WxAccountFansMapper, W
// 2020-11-25 部分用户订阅时间为空,跳过此字段处理 // 2020-11-25 部分用户订阅时间为空,跳过此字段处理
if (ObjectUtil.isNotEmpty(wxMpUser.getSubscribeTime())) { if (ObjectUtil.isNotEmpty(wxMpUser.getSubscribeTime())) {
wxAccountFans.setSubscribeTime(LocalDateTime wxAccountFans.setSubscribeTime(LocalDateTime
.ofInstant(Instant.ofEpochMilli(wxMpUser.getSubscribeTime() * 1000L), ZoneId.systemDefault())); .ofInstant(Instant.ofEpochMilli(wxMpUser.getSubscribeTime() * 1000L), ZoneId.systemDefault()));
} }
// 随机生成一个昵称,方便平台内部使用 // 随机生成一个昵称,方便平台内部使用
@@ -286,8 +288,11 @@ public class WxAccountFansServiceImpl extends ServiceImpl<WxAccountFansMapper, W
*/ */
private String queryNextOpenId(String appId) { private String queryNextOpenId(String appId) {
Page<WxAccountFans> queryPage = new Page<>(0, 1); Page<WxAccountFans> queryPage = new Page<>(0, 1);
Page<WxAccountFans> fansPage = baseMapper.selectPage(queryPage, Wrappers.<WxAccountFans>query().lambda() Page<WxAccountFans> fansPage = baseMapper.selectPage(queryPage,
.eq(WxAccountFans::getWxAccountAppid, appId).orderByDesc(WxAccountFans::getCreateTime)); Wrappers.<WxAccountFans>query()
.lambda()
.eq(WxAccountFans::getWxAccountAppid, appId)
.orderByDesc(WxAccountFans::getCreateTime));
String nextOpenId = null; String nextOpenId = null;
if (fansPage.getTotal() > 0) { if (fansPage.getTotal() > 0) {
nextOpenId = fansPage.getRecords().get(0).getOpenid(); nextOpenId = fansPage.getRecords().get(0).getOpenid();
@@ -64,7 +64,7 @@ public class WxAccountServiceImpl extends ServiceImpl<WxAccountMapper, WxAccount
String url = wxMpService.getQrcodeService().qrCodePictureUrl(ticket.getTicket()); String url = wxMpService.getQrcodeService().qrCodePictureUrl(ticket.getTicket());
WxAccount wxAccount = baseMapper WxAccount wxAccount = baseMapper
.selectOne(Wrappers.<WxAccount>query().lambda().eq(WxAccount::getAppid, appId)); .selectOne(Wrappers.<WxAccount>query().lambda().eq(WxAccount::getAppid, appId));
wxAccount.setQrUrl(url); wxAccount.setQrUrl(url);
baseMapper.updateById(wxAccount); baseMapper.updateById(wxAccount);
} }
@@ -94,29 +94,37 @@ public class WxAccountServiceImpl extends ServiceImpl<WxAccountMapper, WxAccount
List<List<Object>> result = new ArrayList<>(); List<List<Object>> result = new ArrayList<>();
try { try {
// 获取累计用户数据 // 获取累计用户数据
List<Object> cumulateList = cubeService.getUserCumulate(start, end).stream() List<Object> cumulateList = cubeService.getUserCumulate(start, end)
.map(WxDataCubeUserCumulate::getCumulateUser).collect(Collectors.toList()); .stream()
.map(WxDataCubeUserCumulate::getCumulateUser)
.collect(Collectors.toList());
result.add(cumulateList); result.add(cumulateList);
// 获取用户分享数据 // 获取用户分享数据
List<Object> shareList = cubeService.getUserShare(start, end).stream() List<Object> shareList = cubeService.getUserShare(start, end)
.map(WxDataCubeArticleResult::getShareCount).collect(Collectors.toList()); .stream()
.map(WxDataCubeArticleResult::getShareCount)
.collect(Collectors.toList());
result.add(shareList); result.add(shareList);
// 获取消息发送概况数据 // 获取消息发送概况数据
List<Object> upstreamList = cubeService.getUpstreamMsg(start, end).stream() List<Object> upstreamList = cubeService.getUpstreamMsg(start, end)
.map(WxDataCubeMsgResult::getMsgCount).collect(Collectors.toList()); .stream()
.map(WxDataCubeMsgResult::getMsgCount)
.collect(Collectors.toList());
result.add(upstreamList); result.add(upstreamList);
// 获取接口调用概况数据 // 获取接口调用概况数据
List<WxDataCubeInterfaceResult> interfaceSummaryList = cubeService.getInterfaceSummary(start, end); List<WxDataCubeInterfaceResult> interfaceSummaryList = cubeService.getInterfaceSummary(start, end);
List<Object> interfaceList = interfaceSummaryList.stream().map(WxDataCubeInterfaceResult::getCallbackCount) List<Object> interfaceList = interfaceSummaryList.stream()
.collect(Collectors.toList()); .map(WxDataCubeInterfaceResult::getCallbackCount)
.collect(Collectors.toList());
result.add(interfaceList); result.add(interfaceList);
// 接口日期保存 // 接口日期保存
List<Object> dateList = interfaceSummaryList.stream().map(WxDataCubeInterfaceResult::getRefDate) List<Object> dateList = interfaceSummaryList.stream()
.collect(Collectors.toList()); .map(WxDataCubeInterfaceResult::getRefDate)
.collect(Collectors.toList());
result.add(dateList); result.add(dateList);
} }
catch (WxErrorException e) { catch (WxErrorException e) {
@@ -42,7 +42,7 @@ public class WxAccountTagServiceImpl extends ServiceImpl<WxAccountTagMapper, WxA
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public WxAccountTag saveAccountTag(WxAccountTag accountTag) { public WxAccountTag saveAccountTag(WxAccountTag accountTag) {
WxAccountTag wxAccountTag = baseMapper WxAccountTag wxAccountTag = baseMapper
.selectOne(Wrappers.<WxAccountTag>lambdaQuery().eq(WxAccountTag::getTag, accountTag.getTag())); .selectOne(Wrappers.<WxAccountTag>lambdaQuery().eq(WxAccountTag::getTag, accountTag.getTag()));
Assert.isNull(wxAccountTag, StrUtil.format("名称为[{}]的标签已经存在", accountTag.getTag())); Assert.isNull(wxAccountTag, StrUtil.format("名称为[{}]的标签已经存在", accountTag.getTag()));
// 调用微信公众号接口删除 // 调用微信公众号接口删除
@@ -52,7 +52,7 @@ public class WxAccountTagServiceImpl extends ServiceImpl<WxAccountTagMapper, WxA
// 查询公众号详细信息 // 查询公众号详细信息
WxAccount wxAccount = accountMapper WxAccount wxAccount = accountMapper
.selectOne(Wrappers.<WxAccount>lambdaQuery().eq(WxAccount::getAppid, accountTag.getWxAccountAppid())); .selectOne(Wrappers.<WxAccount>lambdaQuery().eq(WxAccount::getAppid, accountTag.getWxAccountAppid()));
accountTag.setWxAccountId(wxAccount.getId()); accountTag.setWxAccountId(wxAccount.getId());
accountTag.setWxAccountAppid(wxAccount.getAppid()); accountTag.setWxAccountAppid(wxAccount.getAppid());
accountTag.setWxAccountName(wxAccount.getName()); accountTag.setWxAccountName(wxAccount.getName());
@@ -64,7 +64,7 @@ public class WxMenuServiceImpl extends ServiceImpl<WxMenuMapper, WxMpMenu> imple
baseMapper.delete(Wrappers.<WxMpMenu>lambdaQuery().eq(WxMpMenu::getWxAccountAppid, appId)); baseMapper.delete(Wrappers.<WxMpMenu>lambdaQuery().eq(WxMpMenu::getWxAccountAppid, appId));
WxAccount wxAccount = wxAccountMapper WxAccount wxAccount = wxAccountMapper
.selectOne(Wrappers.<WxAccount>lambdaQuery().eq(WxAccount::getAppid, appId)); .selectOne(Wrappers.<WxAccount>lambdaQuery().eq(WxAccount::getAppid, appId));
WxMpMenu wxMpMenu = new WxMpMenu(); WxMpMenu wxMpMenu = new WxMpMenu();
wxMpMenu.setMenu(wxMenus.toStringPretty()); wxMpMenu.setMenu(wxMenus.toStringPretty());
wxMpMenu.setWxAccountId(wxAccount.getId()); wxMpMenu.setWxAccountId(wxAccount.getId());
@@ -82,7 +82,7 @@ public class WxMenuServiceImpl extends ServiceImpl<WxMenuMapper, WxMpMenu> imple
@Override @Override
public R push(String appId) { public R push(String appId) {
List<WxMpMenu> wxMpMenuList = baseMapper List<WxMpMenu> wxMpMenuList = baseMapper
.selectList(Wrappers.<WxMpMenu>lambdaQuery().eq(WxMpMenu::getWxAccountAppid, appId)); .selectList(Wrappers.<WxMpMenu>lambdaQuery().eq(WxMpMenu::getWxAccountAppid, appId));
if (CollUtil.isEmpty(wxMpMenuList)) { if (CollUtil.isEmpty(wxMpMenuList)) {
return R.failed("微信菜单配置未保存,不能发布"); return R.failed("微信菜单配置未保存,不能发布");
@@ -118,7 +118,7 @@ public class WxMenuServiceImpl extends ServiceImpl<WxMenuMapper, WxMpMenu> imple
@Override @Override
public R getByAppId(String appId) { public R getByAppId(String appId) {
List<WxMpMenu> wxMpMenuList = baseMapper List<WxMpMenu> wxMpMenuList = baseMapper
.selectList(Wrappers.<WxMpMenu>lambdaQuery().eq(WxMpMenu::getWxAccountAppid, appId)); .selectList(Wrappers.<WxMpMenu>lambdaQuery().eq(WxMpMenu::getWxAccountAppid, appId));
if (CollUtil.isEmpty(wxMpMenuList)) { if (CollUtil.isEmpty(wxMpMenuList)) {
return R.ok(); return R.ok();
@@ -52,7 +52,7 @@ public class WxMsgServiceImpl extends ServiceImpl<WxMsgMapper, WxMsg> implements
// 查询用户详细 // 查询用户详细
WxAccountFans wxUser = accountFansMapper.selectById(wxMsg.getWxUserId()); WxAccountFans wxUser = accountFansMapper.selectById(wxMsg.getWxUserId());
WxAccount wxAccount = accountMapper WxAccount wxAccount = accountMapper
.selectOne(Wrappers.<WxAccount>lambdaQuery().eq(WxAccount::getAppid, wxMsg.getAppId())); .selectOne(Wrappers.<WxAccount>lambdaQuery().eq(WxAccount::getAppid, wxMsg.getAppId()));
// 维护消息-用户 // 维护消息-用户
wxMsg.setNickName(wxAccount.getName()); wxMsg.setNickName(wxAccount.getName());
+1 -1
View File
@@ -6,7 +6,7 @@
<parent> <parent>
<groupId>com.pig4cloud</groupId> <groupId>com.pig4cloud</groupId>
<artifactId>pigx-visual</artifactId> <artifactId>pigx-visual</artifactId>
<version>5.2.0-snapshot</version> <version>5.2.0</version>
</parent> </parent>
<artifactId>pigx-pay-platform</artifactId> <artifactId>pigx-pay-platform</artifactId>
@@ -28,9 +28,12 @@ public class SequenceConfig {
@Bean @Bean
public Sequence paySequence(DataSource dataSource, SequenceDbProperties properties) { public Sequence paySequence(DataSource dataSource, SequenceDbProperties properties) {
return DbSeqBuilder.create() return DbSeqBuilder.create()
.bizName(() -> String.format("pay_%s_%s", TenantContextHolder.getTenantId(), DateUtil.today())) .bizName(() -> String.format("pay_%s_%s", TenantContextHolder.getTenantId(), DateUtil.today()))
.dataSource(dataSource).step(properties.getStep()).retryTimes(properties.getRetryTimes()) .dataSource(dataSource)
.tableName(properties.getTableName()).build(); .step(properties.getStep())
.retryTimes(properties.getRetryTimes())
.tableName(properties.getTableName())
.build();
} }
/** /**
@@ -41,9 +44,13 @@ public class SequenceConfig {
*/ */
@Bean @Bean
public Sequence channelSequence(DataSource dataSource, SequenceDbProperties properties) { public Sequence channelSequence(DataSource dataSource, SequenceDbProperties properties) {
return DbSeqBuilder.create().bizName(() -> String.format("channel_%s", TenantContextHolder.getTenantId())) return DbSeqBuilder.create()
.dataSource(dataSource).step(properties.getStep()).retryTimes(properties.getRetryTimes()) .bizName(() -> String.format("channel_%s", TenantContextHolder.getTenantId()))
.tableName(properties.getTableName()).build(); .dataSource(dataSource)
.step(properties.getStep())
.retryTimes(properties.getRetryTimes())
.tableName(properties.getTableName())
.build();
} }
} }
@@ -107,16 +107,16 @@ public class AlipayPayNotifyCallbackHandler extends AbstractPayNotifyCallbakHand
@Override @Override
public String parse(Map<String, String> params) { public String parse(Map<String, String> params) {
String tradeStatus = EnumUtil.fromString(TradeStatusEnum.class, params.get(PayConstants.TRADE_STATUS)) String tradeStatus = EnumUtil.fromString(TradeStatusEnum.class, params.get(PayConstants.TRADE_STATUS))
.getStatus(); .getStatus();
String orderNo = params.get(PayConstants.OUT_TRADE_NO); String orderNo = params.get(PayConstants.OUT_TRADE_NO);
PayGoodsOrder goodsOrder = goodsOrderService PayGoodsOrder goodsOrder = goodsOrderService
.getOne(Wrappers.<PayGoodsOrder>lambdaQuery().eq(PayGoodsOrder::getPayOrderId, orderNo)); .getOne(Wrappers.<PayGoodsOrder>lambdaQuery().eq(PayGoodsOrder::getPayOrderId, orderNo));
goodsOrder.setStatus(tradeStatus); goodsOrder.setStatus(tradeStatus);
goodsOrderService.updateById(goodsOrder); goodsOrderService.updateById(goodsOrder);
PayTradeOrder tradeOrder = tradeOrderService PayTradeOrder tradeOrder = tradeOrderService
.getOne(Wrappers.<PayTradeOrder>lambdaQuery().eq(PayTradeOrder::getOrderId, orderNo)); .getOne(Wrappers.<PayTradeOrder>lambdaQuery().eq(PayTradeOrder::getOrderId, orderNo));
tradeOrder.setPaySuccTime(LocalDateTime.now()); tradeOrder.setPaySuccTime(LocalDateTime.now());
tradeOrder.setChannelOrderNo(params.get("trade_no")); tradeOrder.setChannelOrderNo(params.get("trade_no"));
tradeOrder.setStatus(TradeStatusEnum.TRADE_SUCCESS.getStatus()); tradeOrder.setStatus(TradeStatusEnum.TRADE_SUCCESS.getStatus());
@@ -57,10 +57,14 @@ public class AlipayPayOrderRefundHandler implements PayOrderRefundHandler {
} }
JSONObject params = JSONUtil.parseObj(channel.getParam()); JSONObject params = JSONUtil.parseObj(channel.getParam());
AliPayApiConfig aliPayApiConfig = AliPayApiConfig.builder().setAppId(channel.getAppId()) AliPayApiConfig aliPayApiConfig = AliPayApiConfig.builder()
.setPrivateKey(params.getStr("privateKey")).setCharset(CharsetUtil.UTF_8) .setAppId(channel.getAppId())
.setAliPayPublicKey(params.getStr("publicKey")).setServiceUrl(params.getStr("serviceUrl")) .setPrivateKey(params.getStr("privateKey"))
.setSignType("RSA2").build(); .setCharset(CharsetUtil.UTF_8)
.setAliPayPublicKey(params.getStr("publicKey"))
.setServiceUrl(params.getStr("serviceUrl"))
.setSignType("RSA2")
.build();
AliPayApiConfigKit.setThreadLocalAliPayApiConfig(aliPayApiConfig); AliPayApiConfigKit.setThreadLocalAliPayApiConfig(aliPayApiConfig);
return channel; return channel;
} }
@@ -81,10 +81,14 @@ public class AlipayWapPayOrderHandler extends AbstractPayOrderHandler {
} }
JSONObject params = JSONUtil.parseObj(channel.getParam()); JSONObject params = JSONUtil.parseObj(channel.getParam());
AliPayApiConfig aliPayApiConfig = AliPayApiConfig.builder().setAppId(channel.getAppId()) AliPayApiConfig aliPayApiConfig = AliPayApiConfig.builder()
.setPrivateKey(params.getStr("privateKey")).setCharset(CharsetUtil.UTF_8) .setAppId(channel.getAppId())
.setAliPayPublicKey(params.getStr("publicKey")).setServiceUrl(params.getStr("serviceUrl")) .setPrivateKey(params.getStr("privateKey"))
.setSignType("RSA2").build(); .setCharset(CharsetUtil.UTF_8)
.setAliPayPublicKey(params.getStr("publicKey"))
.setServiceUrl(params.getStr("serviceUrl"))
.setSignType("RSA2")
.build();
AliPayApiConfigKit.setThreadLocalAliPayApiConfig(aliPayApiConfig); AliPayApiConfigKit.setThreadLocalAliPayApiConfig(aliPayApiConfig);
return channel; return channel;
} }
@@ -79,8 +79,11 @@ public class WeChatMpPayOrderHandler extends AbstractPayOrderHandler {
} }
JSONObject params = JSONUtil.parseObj(channel.getParam()); JSONObject params = JSONUtil.parseObj(channel.getParam());
WxPayApiConfig wx = WxPayApiConfig.builder().appId(channel.getAppId()).mchId(channel.getChannelMchId()) WxPayApiConfig wx = WxPayApiConfig.builder()
.partnerKey(params.getStr("partnerKey")).build(); .appId(channel.getAppId())
.mchId(channel.getChannelMchId())
.partnerKey(params.getStr("partnerKey"))
.build();
WxPayApiConfigKit.setThreadLocalWxPayApiConfig(wx); WxPayApiConfigKit.setThreadLocalWxPayApiConfig(wx);
return channel; return channel;
@@ -117,14 +120,20 @@ public class WeChatMpPayOrderHandler extends AbstractPayOrderHandler {
WxPayApiConfig wxPayApiConfig = WxPayApiConfigKit.getWxPayApiConfig(); WxPayApiConfig wxPayApiConfig = WxPayApiConfigKit.getWxPayApiConfig();
// 预订单参数 // 预订单参数
Map<String, String> params = UnifiedOrderModel.builder().appid(wxPayApiConfig.getAppId()) Map<String, String> params = UnifiedOrderModel.builder()
.mch_id(wxPayApiConfig.getMchId()).nonce_str(WxPayKit.generateStr()).body(goodsOrder.getGoodsName()) .appid(wxPayApiConfig.getAppId())
.attach(TenantContextHolder.getTenantId().toString()) .mch_id(wxPayApiConfig.getMchId())
.out_trade_no(String.valueOf(tradeOrder.getOrderId())).total_fee(goodsOrder.getAmount()) .nonce_str(WxPayKit.generateStr())
.spbill_create_ip(ip) .body(goodsOrder.getGoodsName())
.notify_url(ChannelPayApiConfigKit.get().getNotifyUrl() + "/admin/notify/wx/callbak") .attach(TenantContextHolder.getTenantId().toString())
.trade_type(TradeType.JSAPI.getTradeType()).openid(goodsOrder.getUserId()).build() .out_trade_no(String.valueOf(tradeOrder.getOrderId()))
.createSign(wxPayApiConfig.getPartnerKey(), SignType.HMACSHA256); .total_fee(goodsOrder.getAmount())
.spbill_create_ip(ip)
.notify_url(ChannelPayApiConfigKit.get().getNotifyUrl() + "/admin/notify/wx/callbak")
.trade_type(TradeType.JSAPI.getTradeType())
.openid(goodsOrder.getUserId())
.build()
.createSign(wxPayApiConfig.getPartnerKey(), SignType.HMACSHA256);
String xmlResult = WxPayApi.pushOrder(false, params); String xmlResult = WxPayApi.pushOrder(false, params);
log.info("微信统一下单返回 {}", xmlResult); log.info("微信统一下单返回 {}", xmlResult);
@@ -102,16 +102,16 @@ public class WeChatPayNotifyCallbackHandler extends AbstractPayNotifyCallbakHand
@Override @Override
public String parse(Map<String, String> params) { public String parse(Map<String, String> params) {
String tradeStatus = EnumUtil.fromString(TradeStatusEnum.class, params.get(PayConstants.RESULT_CODE)) String tradeStatus = EnumUtil.fromString(TradeStatusEnum.class, params.get(PayConstants.RESULT_CODE))
.getStatus(); .getStatus();
String orderNo = params.get(PayConstants.OUT_TRADE_NO); String orderNo = params.get(PayConstants.OUT_TRADE_NO);
PayGoodsOrder goodsOrder = goodsOrderService PayGoodsOrder goodsOrder = goodsOrderService
.getOne(Wrappers.<PayGoodsOrder>lambdaQuery().eq(PayGoodsOrder::getPayOrderId, orderNo)); .getOne(Wrappers.<PayGoodsOrder>lambdaQuery().eq(PayGoodsOrder::getPayOrderId, orderNo));
goodsOrder.setStatus(tradeStatus); goodsOrder.setStatus(tradeStatus);
goodsOrderService.updateById(goodsOrder); goodsOrderService.updateById(goodsOrder);
PayTradeOrder tradeOrder = tradeOrderService PayTradeOrder tradeOrder = tradeOrderService
.getOne(Wrappers.<PayTradeOrder>lambdaQuery().eq(PayTradeOrder::getOrderId, orderNo)); .getOne(Wrappers.<PayTradeOrder>lambdaQuery().eq(PayTradeOrder::getOrderId, orderNo));
tradeOrder.setPaySuccTime(LocalDateTime.now()); tradeOrder.setPaySuccTime(LocalDateTime.now());
tradeOrder.setStatus(tradeStatus); tradeOrder.setStatus(tradeStatus);
tradeOrder.setChannelOrderNo(params.get("transaction_id")); tradeOrder.setChannelOrderNo(params.get("transaction_id"));
@@ -86,9 +86,9 @@ public class YungouosMergePayNotifyCallbakHandler extends AbstractPayNotifyCallb
String mergeCode = params.get(PayConstants.MERGE_CODE); String mergeCode = params.get(PayConstants.MERGE_CODE);
String orderNo = params.get(PayConstants.MERGE_OUT_TRADE_NO); String orderNo = params.get(PayConstants.MERGE_OUT_TRADE_NO);
PayGoodsOrder goodsOrder = goodsOrderService PayGoodsOrder goodsOrder = goodsOrderService
.getOne(Wrappers.<PayGoodsOrder>lambdaQuery().eq(PayGoodsOrder::getPayOrderId, orderNo)); .getOne(Wrappers.<PayGoodsOrder>lambdaQuery().eq(PayGoodsOrder::getPayOrderId, orderNo));
PayTradeOrder tradeOrder = tradeOrderService PayTradeOrder tradeOrder = tradeOrderService
.getOne(Wrappers.<PayTradeOrder>lambdaQuery().eq(PayTradeOrder::getOrderId, orderNo)); .getOne(Wrappers.<PayTradeOrder>lambdaQuery().eq(PayTradeOrder::getOrderId, orderNo));
if (OrderStatusEnum.SUCCESS.getStatus().equals(mergeCode)) { if (OrderStatusEnum.SUCCESS.getStatus().equals(mergeCode)) {
goodsOrder.setStatus(OrderStatusEnum.SUCCESS.getStatus()); goodsOrder.setStatus(OrderStatusEnum.SUCCESS.getStatus());
+1 -1
View File
@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>com.pig4cloud</groupId> <groupId>com.pig4cloud</groupId>
<artifactId>pigx-visual</artifactId> <artifactId>pigx-visual</artifactId>
<version>5.2.0-snapshot</version> <version>5.2.0</version>
</parent> </parent>
<artifactId>pigx-report-platform</artifactId> <artifactId>pigx-report-platform</artifactId>
+1 -1
View File
@@ -24,7 +24,7 @@
<parent> <parent>
<groupId>com.pig4cloud</groupId> <groupId>com.pig4cloud</groupId>
<artifactId>pigx</artifactId> <artifactId>pigx</artifactId>
<version>5.2.0-snapshot</version> <version>5.2.0</version>
</parent> </parent>
<artifactId>pigx-visual</artifactId> <artifactId>pigx-visual</artifactId>
+1 -1
View File
@@ -24,7 +24,7 @@
<groupId>com.pig4cloud</groupId> <groupId>com.pig4cloud</groupId>
<artifactId>pigx</artifactId> <artifactId>pigx</artifactId>
<version>5.2.0-snapshot</version> <version>5.2.0</version>
<name>${project.artifactId}</name> <name>${project.artifactId}</name>
<packaging>pom</packaging> <packaging>pom</packaging>
<organization> <organization>