|
@@ -5,6 +5,7 @@ import java.util.Comparator;
|
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.Map.Entry;
|
|
import java.util.Map.Entry;
|
|
|
|
|
+import java.util.TreeSet;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
import javax.script.Bindings;
|
|
import javax.script.Bindings;
|
|
@@ -981,22 +982,28 @@ public class AeiObjects extends GsonPropertyObject {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void commitReadCreatePart() {
|
|
private void commitReadCreatePart() {
|
|
|
- this.getCreateReads().stream().forEach(o -> {
|
|
|
|
|
- Read obj;
|
|
|
|
|
- try {
|
|
|
|
|
- obj = this.getReads().stream().filter(p -> StringUtils.equals(o.getJob(), p.getJob())
|
|
|
|
|
- && StringUtils.equals(o.getPerson(), p.getPerson())).findFirst().orElse(null);
|
|
|
|
|
- if (null == obj) {
|
|
|
|
|
- this.business.entityManagerContainer().persist(o, CheckPersistType.all);
|
|
|
|
|
- /* 创建待阅的参阅 */
|
|
|
|
|
- this.createReview(new Review(this.getWork(), o.getPerson()));
|
|
|
|
|
- } else {
|
|
|
|
|
- o.copyTo(obj, JpaObject.FieldsUnmodify);
|
|
|
|
|
- }
|
|
|
|
|
- } catch (Exception e) {
|
|
|
|
|
- logger.error(e);
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ // 去重可能的在同一次提交中产生的对同一个人的多份Read
|
|
|
|
|
+ this.getCreateReads().stream()
|
|
|
|
|
+ .collect(Collectors.collectingAndThen(
|
|
|
|
|
+ Collectors.toCollection(
|
|
|
|
|
+ () -> new TreeSet<>(Comparator.comparing(o -> o.getPerson() + o.getJob()))),
|
|
|
|
|
+ ArrayList::new))
|
|
|
|
|
+ .stream().forEach(o -> {
|
|
|
|
|
+ Read obj;
|
|
|
|
|
+ try {
|
|
|
|
|
+ obj = this.getReads().stream().filter(p -> StringUtils.equals(o.getJob(), p.getJob())
|
|
|
|
|
+ && StringUtils.equals(o.getPerson(), p.getPerson())).findFirst().orElse(null);
|
|
|
|
|
+ if (null == obj) {
|
|
|
|
|
+ this.business.entityManagerContainer().persist(o, CheckPersistType.all);
|
|
|
|
|
+ /* 创建待阅的参阅 */
|
|
|
|
|
+ this.createReview(new Review(this.getWork(), o.getPerson()));
|
|
|
|
|
+ } else {
|
|
|
|
|
+ o.copyTo(obj, JpaObject.FieldsUnmodify);
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ logger.error(e);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void commitReadUpdatePart() {
|
|
private void commitReadUpdatePart() {
|
|
@@ -1095,22 +1102,28 @@ public class AeiObjects extends GsonPropertyObject {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void commitReviewCreatePart() {
|
|
private void commitReviewCreatePart() {
|
|
|
- this.getCreateReviews().stream().forEach(o -> {
|
|
|
|
|
- Review obj;
|
|
|
|
|
- try {
|
|
|
|
|
- /* 参阅唯一 */
|
|
|
|
|
- obj = this.getReviews().stream().filter(p -> StringUtils.equals(o.getJob(), p.getJob())
|
|
|
|
|
- && StringUtils.equals(o.getPerson(), p.getPerson())).findFirst().orElse(null);
|
|
|
|
|
- if (null == obj) {
|
|
|
|
|
- this.business.entityManagerContainer().persist(o, CheckPersistType.all);
|
|
|
|
|
- } else {
|
|
|
|
|
- // 如果逻辑上相同的已阅已经存在,覆盖内容.
|
|
|
|
|
- o.copyTo(obj, JpaObject.FieldsUnmodify);
|
|
|
|
|
- }
|
|
|
|
|
- } catch (Exception e) {
|
|
|
|
|
- logger.error(e);
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ // 去重可能的在同一次提交中产生的对同一个人的多份Review
|
|
|
|
|
+ this.getCreateReviews().stream()
|
|
|
|
|
+ .collect(Collectors.collectingAndThen(
|
|
|
|
|
+ Collectors.toCollection(
|
|
|
|
|
+ () -> new TreeSet<>(Comparator.comparing(o -> o.getPerson() + o.getJob()))),
|
|
|
|
|
+ ArrayList::new))
|
|
|
|
|
+ .stream().forEach(o -> {
|
|
|
|
|
+ Review obj;
|
|
|
|
|
+ try {
|
|
|
|
|
+ /* 参阅唯一 */
|
|
|
|
|
+ obj = this.getReviews().stream().filter(p -> StringUtils.equals(o.getJob(), p.getJob())
|
|
|
|
|
+ && StringUtils.equals(o.getPerson(), p.getPerson())).findFirst().orElse(null);
|
|
|
|
|
+ if (null == obj) {
|
|
|
|
|
+ this.business.entityManagerContainer().persist(o, CheckPersistType.all);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 如果逻辑上相同的已阅已经存在,覆盖内容.
|
|
|
|
|
+ o.copyTo(obj, JpaObject.FieldsUnmodify);
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ logger.error(e);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void commitReviewUpdatePart() {
|
|
private void commitReviewUpdatePart() {
|