Skip to content

Commit ec222bc

Browse files
getrebuilddevezhao
andauthored
enh: TriggerByTimerJob 未完成也可重进 (#731)
* enh: TriggerByTimerJob 未完成也可重进 * enh: fileName use#698 * feat: UseDbFullText * !!!@EnableAsync --------- Co-authored-by: devezhao <[email protected]>
1 parent df03b4a commit ec222bc

27 files changed

+119
-78
lines changed

@rbv

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Subproject commit 0cd82a86500483425282eb70acee2d672aed36a2
1+
Subproject commit a56f9d641a7fb564e80876cc6f5111fb95737e63

src/main/java/com/rebuild/core/BootApplication.java

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.springframework.boot.context.ApplicationPidFileWriter;
2626
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
2727
import org.springframework.context.annotation.ImportResource;
28+
import org.springframework.scheduling.annotation.EnableAsync;
2829
import org.springframework.scheduling.annotation.EnableScheduling;
2930

3031
import javax.management.MBeanServer;
@@ -55,6 +56,7 @@
5556
H2ConsoleAutoConfiguration.class})
5657
@ImportResource("classpath:application-bean.xml")
5758
@EnableScheduling
59+
@EnableAsync
5860
@Slf4j
5961
public class BootApplication extends SpringBootServletInitializer {
6062

src/main/java/com/rebuild/core/BootConfiguration.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@
4545
public class BootConfiguration implements InstallState {
4646

4747
/**
48-
* Fake instance
49-
* FIXME 直接 `==` 比较不安全 ???
48+
* ghost instance
5049
*/
5150
public static final JedisPool USE_EHCACHE = new JedisPool(
5251
KnownJedisPool.DEFAULT_CONFIG, "127.0.0.1", 6379);

src/main/java/com/rebuild/core/metadata/MetadataHelper.java

-1
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,6 @@ public static boolean checkAndWarnField(String entityName, String fieldName) {
417417

418418
/**
419419
* 实体分类标签
420-
* TODO 性能
421420
*
422421
* @return
423422
*/

src/main/java/com/rebuild/core/metadata/easymeta/DisplayType.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ public enum DisplayType {
3939
BOOL(EasyBool.class, "布尔", FieldType.BOOL, FieldType.NO_NEED_LENGTH, null),
4040
BARCODE(EasyBarCode.class, "二维码", FieldType.STRING, 300, null, false, true),
4141
N2NREFERENCE(EasyN2NReference.class, "多引用", FieldType.REFERENCE_LIST, -1, null),
42-
LOCATION(EasyLocation.class, "位置", FieldType.STRING, 100, null),
42+
LOCATION(EasyLocation.class, "位置", FieldType.STRING, 200, null),
4343
SIGN(EasySign.class, "签名", FieldType.TEXT, 32767, null, false, true),
44-
TAG(EasyTag.class, "标签", FieldType.STRING, 100, null),
44+
TAG(EasyTag.class, "标签", FieldType.STRING, 40, null),
4545

4646
// 内部
4747

src/main/java/com/rebuild/core/metadata/easymeta/EasyAnyReference.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import org.springframework.util.Assert;
1717

1818
/**
19-
* TODO 暂不开放开放应注意触发器/记录转换等处的填值
19+
* 暂不开放开放应注意触发器/记录转换等处的填值
2020
*
2121
* @author devezhao
2222
* @since 2020/11/17

src/main/java/com/rebuild/core/privileges/DepartmentService.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,8 @@ public int delete(ID recordId) {
8585
}
8686

8787
/**
88-
* TODO 删除后转移成员到其他部门
89-
*
9088
* @param deptId
91-
* @param transferTo
89+
* @param transferTo 删除后转移成员到其他部门
9290
*/
9391
public void deleteAndTransfer(ID deptId, ID transferTo) {
9492
if (ROOT_DEPT.equals(deptId)) {

src/main/java/com/rebuild/core/privileges/PrivilegesManager.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ public boolean allow(ID user, int entity, Permission action) {
219219
return true;
220220
}
221221

222-
// FIXME v35 批量审批无权限
222+
// 审批无权限校验
223223
if (action == InternalPermission.APPROVAL) return true;
224224

225225
Boolean a = userAllow(user);

src/main/java/com/rebuild/core/privileges/RoleService.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,8 @@ public int delete(ID roleId) {
6666
}
6767

6868
/**
69-
* TODO 删除后转移成员到其他角色
70-
*
7169
* @param roleId
72-
* @param transferTo
70+
* @param transferTo 删除后转移成员到其他角色
7371
*/
7472
public void deleteAndTransfer(ID roleId, ID transferTo) {
7573
if (roleId.equals(ADMIN_ROLE)) {

src/main/java/com/rebuild/core/service/files/FilesHelper.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import com.rebuild.core.Application;
1515
import com.rebuild.core.metadata.EntityHelper;
1616
import com.rebuild.core.privileges.UserHelper;
17+
import com.rebuild.core.support.integration.QiniuCloud;
1718
import com.rebuild.utils.JSONUtils;
1819
import org.apache.commons.collections4.CollectionUtils;
1920
import org.apache.commons.collections4.map.LRUMap;
@@ -61,6 +62,7 @@ public static void storeFileSize(String filePath, int fileSize) {
6162
public static Record createAttachment(String filePath, ID user) {
6263
Record attach = EntityHelper.forNew(EntityHelper.Attachment, user);
6364
attach.setString("filePath", filePath);
65+
attach.setString("fileName", QiniuCloud.parseFileName(filePath));
6466

6567
String ext = FilenameUtils.getExtension(filePath);
6668
if (StringUtils.isNotBlank(ext)) {
@@ -69,7 +71,7 @@ public static Record createAttachment(String filePath, ID user) {
6971
}
7072

7173
if (FILESIZES.containsKey(filePath)) {
72-
attach.setInt("fileSize", FILESIZES.remove(filePath));
74+
attach.setInt("fileSize", FILESIZES.get(filePath));
7375
} else {
7476
Object[] db = Application.createQueryNoFilter(
7577
"select fileSize from Attachment where filePath = ?")

src/main/java/com/rebuild/core/service/trigger/aviator/TextFunction.java

-2
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,6 @@ public AviatorObject call(Map<String, Object> env, AviatorObject arg1, AviatorOb
110110
log.warn("Invalid value with type : {}", $id);
111111
}
112112

113-
// TODO 更多字段类型支持
114-
115113
return arg2;
116114
}
117115

src/main/java/com/rebuild/core/support/ConfigurationItem.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ SmsUser, SmsPassword, SmsSign(AppName),
115115
PortalUploadMaxSize(200),
116116
MobileNavStyle(34),
117117
PageMourningMode(false),
118-
118+
119119
// !!! 命令行适用
120120
DataDirectory, // 数据目录
121121
RedisDatabase(0), // Redis DB
@@ -126,6 +126,7 @@ SmsUser, SmsPassword, SmsSign(AppName),
126126
TrustedAllUrl(false), // 可信外部地址
127127
LibreofficeBin, // Libreoffice 命令
128128
UnsafeImgAccess(false), // 不安全图片访问
129+
UseDbFullText(false), // 对支持的字段启用全文索引查询
129130

130131
;
131132

@@ -145,6 +146,7 @@ public static boolean inJvmArgs(String name) {
145146
|| TrustedAllUrl.name().equalsIgnoreCase(name)
146147
|| LibreofficeBin.name().equalsIgnoreCase(name)
147148
|| UnsafeImgAccess.name().equals(name)
149+
|| UseDbFullText.name().equals(name)
148150
|| SN.name().equalsIgnoreCase(name);
149151
}
150152

src/main/java/com/rebuild/core/support/distributed/DistributedJobLock.java

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
*
2525
* @author ZHAO
2626
* @since 2020/4/5
27+
* @see DistributedSupport
2728
*/
2829
@Slf4j
2930
public abstract class DistributedJobLock {

src/main/java/com/rebuild/core/support/setup/DatabaseFixer.java

+28
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import cn.devezhao.persist4j.Field;
1414
import cn.devezhao.persist4j.Record;
1515
import cn.devezhao.persist4j.engine.ID;
16+
import cn.devezhao.persist4j.util.support.QueryHelper;
1617
import com.rebuild.core.Application;
1718
import com.rebuild.core.metadata.EntityHelper;
1819
import com.rebuild.core.metadata.MetadataHelper;
@@ -23,6 +24,7 @@
2324
import com.rebuild.core.support.ConfigurationItem;
2425
import com.rebuild.core.support.KVStorage;
2526
import com.rebuild.core.support.RebuildConfiguration;
27+
import com.rebuild.core.support.integration.QiniuCloud;
2628
import lombok.extern.slf4j.Slf4j;
2729
import org.apache.commons.lang.BooleanUtils;
2830

@@ -37,6 +39,7 @@ public class DatabaseFixer {
3739

3840
private static final String KEY_41 = "DataMigratorV41";
3941
private static final String KEY_346 = "DatabaseFixerV346";
42+
private static final String KEY_370 = "DatabaseFixerV370";
4043

4144
/**
4245
* 辅助数据库升级
@@ -69,6 +72,19 @@ public static void fixIfNeed() {
6972
}
7073
});
7174
}
75+
76+
if (dbVer <= 55 && !BooleanUtils.toBoolean(KVStorage.getCustomValue(KEY_370))) {
77+
log.info("Database fixing `V370` ...");
78+
ThreadPool.exec(() -> {
79+
try {
80+
fixV370();
81+
KVStorage.setCustomValue(KEY_370, "true");
82+
log.info("Database fixed `V370` all succeeded");
83+
} catch (Exception ex) {
84+
log.error("Database fixing `V370` failed : {}", ThrowableUtils.getRootCause(ex).getLocalizedMessage());
85+
}
86+
});
87+
}
7288
}
7389

7490
// #41:多引用字段改为三方表
@@ -130,4 +146,16 @@ private static void fixV346() {
130146
}
131147
}
132148
}
149+
150+
// V370:补充附件文件名称
151+
private static void fixV370() {
152+
Object[][] atts = QueryHelper.readArray(
153+
Application.createQueryNoFilter("select attachmentId,filePath from Attachment"));
154+
for (Object[] o : atts) {
155+
String fileName = QiniuCloud.parseFileName((String) o[1]);
156+
Record record = EntityHelper.forUpdate((ID) o[0], UserService.SYSTEM_USER, false);
157+
record.setString("fileName", fileName);
158+
Application.getCommonsService().update(record, false);
159+
}
160+
}
133161
}

src/main/java/com/rebuild/web/admin/ApisManagerController.java

+8-3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
import com.rebuild.core.Application;
1818
import com.rebuild.core.configuration.RebuildApiService;
1919
import com.rebuild.core.metadata.EntityHelper;
20+
import com.rebuild.core.support.ConfigurationItem;
21+
import com.rebuild.core.support.RebuildConfiguration;
2022
import com.rebuild.core.support.i18n.I18nUtils;
2123
import com.rebuild.utils.CommonsUtils;
2224
import com.rebuild.web.BaseController;
@@ -89,9 +91,12 @@ public RespBody requestLogs(HttpServletRequest request) {
8991
" where appId = ? and requestTime > ? and (1=1) order by requestTime desc";
9092
if (StringUtils.isNotBlank(q)) {
9193
q = CommonsUtils.escapeSql(q);
92-
sql = sql.replace("(1=1)", String.format("(requestBody like '%%%s%%' or responseBody like '%%%s%%')", q, q));
93-
// // TODO 使用全文索引搜索
94-
// sql = sql.replace("(1=1)", String.format("(requestBody match '%s' or responseBody match '%s')", q, q));
94+
// https://zhuanlan.zhihu.com/p/35675553
95+
if (RebuildConfiguration.getBool(ConfigurationItem.UseDbFullText)) {
96+
sql = sql.replace("(1=1)", String.format("(requestBody match '%s' or responseBody match '%s')", q, q));
97+
} else {
98+
sql = sql.replace("(1=1)", String.format("(requestBody like '%%%s%%' or responseBody like '%%%s%%')", q, q));
99+
}
95100
}
96101

97102
Object[][] array = Application.createQueryNoFilter(sql)

src/main/java/com/rebuild/web/admin/bizz/DepartmentController.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,8 @@ public ModelAndView pageList(HttpServletRequest request) {
4848

4949
@PostMapping("dept-delete")
5050
public RespBody deptDelete(@IdParam ID deptId, HttpServletRequest request) {
51-
ID transfer = getIdParameter(request, "transfer"); // TODO 转移到新部门
52-
53-
Application.getBean(DepartmentService.class).deleteAndTransfer(deptId, transfer);
51+
ID transferTo = getIdParameter(request, "transfer"); // TODO 转移到新部门
52+
Application.getBean(DepartmentService.class).deleteAndTransfer(deptId, transferTo);
5453
return RespBody.ok();
5554
}
5655

src/main/java/com/rebuild/web/admin/bizz/RolePrivilegesController.java

+8-4
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,12 @@
2121
import com.rebuild.utils.JSONUtils;
2222
import com.rebuild.web.EntityController;
2323
import com.rebuild.web.IdParam;
24-
import org.springframework.web.bind.annotation.*;
24+
import org.springframework.web.bind.annotation.GetMapping;
25+
import org.springframework.web.bind.annotation.PathVariable;
26+
import org.springframework.web.bind.annotation.PostMapping;
27+
import org.springframework.web.bind.annotation.RequestBody;
28+
import org.springframework.web.bind.annotation.RequestMapping;
29+
import org.springframework.web.bind.annotation.RestController;
2530
import org.springframework.web.servlet.ModelAndView;
2631

2732
import javax.servlet.http.HttpServletRequest;
@@ -115,9 +120,8 @@ public RespBody privilegesUpdate(@IdParam(name = "role") ID roleId, HttpServletR
115120

116121
@PostMapping("role-delete")
117122
public RespBody roleDelete(@IdParam ID roleId, HttpServletRequest request) {
118-
ID transfer = getIdParameter(request, "transfer"); // TODO 转移到新角色
119-
120-
Application.getBean(RoleService.class).deleteAndTransfer(roleId, transfer);
123+
ID transferTo = getIdParameter(request, "transfer"); // TODO 转移到新角色
124+
Application.getBean(RoleService.class).deleteAndTransfer(roleId, transferTo);
121125
return RespBody.ok();
122126
}
123127

src/main/java/com/rebuild/web/feeds/FeedsListController.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,7 @@ public RespBody fetchFeeds(HttpServletRequest request) {
112112
if (pageNo == 1) {
113113
count = (Long) Application.createQueryNoFilter(
114114
"select count(feedsId) from Feeds where " + sqlWhere).unique()[0];
115-
if (count == 0) {
116-
return RespBody.ok();
117-
}
115+
if (count == 0) return RespBody.ok();
118116
}
119117

120118
String sql = ITEM_SQL + sqlWhere;

src/main/java/com/rebuild/web/files/FileListController.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public JSON listFile(HttpServletRequest request) {
103103

104104
List<String> sqlWhere = new ArrayList<>();
105105
if (StringUtils.isNotBlank(q)) {
106-
sqlWhere.add(String.format("filePath like '%%%s%%'", CommonsUtils.escapeSql(q)));
106+
sqlWhere.add(String.format("fileName like '%%%s%%'", CommonsUtils.escapeSql(q)));
107107
}
108108

109109
// 附件

src/main/resources/metadata-conf.xml

+5-3
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,11 @@
228228
<field name="filePath" type="string" max-length="191" nullable="false" description="文件路径"/>
229229
<field name="fileType" type="string" max-length="20" description="文件类型"/>
230230
<field name="fileSize" type="int" default-value="0" description="文件大小"/>
231+
<field name="fileName" type="string" max-length="100" description="文件名称"/>
231232
<field name="inFolder" type="reference" ref-entity="AttachmentFolder" description="所在目录"/>
232233
<field name="isDeleted" type="bool" default-value="F" description="是否删除"/>
233-
<index field-list="belongEntity,belongField,filePath,isDeleted"/>
234-
<index field-list="inFolder,createdOn,filePath"/>
234+
<index field-list="belongEntity,belongField,fileName,isDeleted"/>
235+
<index field-list="inFolder,createdOn,fileName"/>
235236
<index field-list="relatedRecord"/>
236237
</entity>
237238

@@ -303,14 +304,14 @@
303304
<index field-list="recordId,approvalId,node,isCanceled,isWaiting,isBacked,nodeBatch"/>
304305
</entity>
305306

307+
<!--
306308
<entity name="RobotSopConfig" type-code="070" name-field="name" description="操作流程/业务进度" queryable="false">
307309
<field name="configId" type="primary"/>
308310
<field name="belongEntity" type="string" max-length="100" nullable="false" updatable="false" description="应用实体"/>
309311
<field name="name" type="string" max-length="100" nullable="false" description="流程名称"/>
310312
<field name="sopDefinition" type="text" description="流程定义"/>
311313
<field name="isDisabled" type="bool" default-value="F" description="是否禁用"/>
312314
</entity>
313-
314315
<entity name="RobotSopStep" type-code="071" description="操作流程步骤" queryable="false">
315316
<field name="stepId" type="primary"/>
316317
<field name="recordId" type="any-reference" nullable="false" updatable="false" description="业务记录"/>
@@ -322,6 +323,7 @@
322323
<field name="operationContent" type="text" updatable="false" description="操作内容"/>
323324
<field name="state" type="small-int" default-value="1" description="状态"/>
324325
</entity>
326+
-->
325327

326328
<entity name="RebuildApi" type-code="030" description="API 密钥" queryable="false">
327329
<field name="uniqueId" type="primary"/>

0 commit comments

Comments
 (0)