Commit 7ffc6f21 authored by 鲁鸿波's avatar 鲁鸿波

值班日志人员按顺序导入显示

parent a39ad782
......@@ -46,4 +46,6 @@ public class Person {
private String dutyLogDraft;
@ApiModelProperty(value = "日志是否暂存")
private String dutyLogId;
@ApiModelProperty(value = "排序")
private Integer sort;
}
......@@ -74,6 +74,7 @@ import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAdjusters;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collector;
import java.util.stream.Collectors;
......@@ -850,7 +851,15 @@ public class DutyServiceImpl extends ServiceImpl<DutyDao, TSysDuty> implements D
}
//存储同一天多个人到list
people.add(person);
List<Person> collect1 = people.stream().sorted(Comparator.comparing(Person::getCreateDate).thenComparing(Person::getId)).collect(Collectors.toList());
//List<Person> collect1 = people.stream().sorted(Comparator.comparing(Person::getCreateDate).thenComparing(Person::getId)).collect(Collectors.toList());
List<Person> collect1 = people.stream()
.sorted(
Comparator.comparing(Person::getCreateDate)
.thenComparing(Person::getSort) // 新增sort升序排序
.thenComparing(Person::getId)
)
.collect(Collectors.toList());
duty.setPersonList(collect1);
}
duties.add(duty);
......@@ -974,9 +983,20 @@ public class DutyServiceImpl extends ServiceImpl<DutyDao, TSysDuty> implements D
//获取年月对应表id
TSysDuty dutyMonthId = getDutyMonthId(list, tSysDuty, sysOrg, loginUser);
String monthId = dutyMonthId.getId();
list.stream().forEach(item -> {
/*list.stream().forEach(item -> {
Person person = this.saveDuty(item, tSysDuty, sysOrg, loginUser, monthId);
people.add(person);
});*/
// 创建自增索引计数器 - 从1开始(若需要从0开始则用0)
AtomicInteger index = new AtomicInteger(1);
list.stream().forEach(item -> {
Person person = this.saveDuty(item, tSysDuty, sysOrg, loginUser, monthId,index.getAndIncrement());
people.add(person);
});
response.setData(people);
// 导入成功启动流程
......@@ -1258,7 +1278,7 @@ public class DutyServiceImpl extends ServiceImpl<DutyDao, TSysDuty> implements D
}
@SneakyThrows
public Person saveDuty(Map<Integer, Object> item, TSysDuty duty, SysOrg sysOrg, UserInfo loginUser, String monthId) {
public Person saveDuty(Map<Integer, Object> item, TSysDuty duty, SysOrg sysOrg, UserInfo loginUser, String monthId,int index) {
TSysDuty tSysDuty = BeanHelper.beanToBean(duty, TSysDuty.class);
String month = item.get(3)+"";
String day = item.get(4)+"";
......@@ -1297,6 +1317,7 @@ public class DutyServiceImpl extends ServiceImpl<DutyDao, TSysDuty> implements D
tSysDuty.setTenantId(duty.getTenantId());
tSysDuty.setStatus("0");
tSysDuty.setProcessStatus("3");
tSysDuty.setSort(index);
QueryWrapper<TSysDuty> queryWrapper = new QueryWrapper<>();
if (ObjectHelper.isNotEmpty(tSysDuty.getTenantId())) {
queryWrapper.eq("tenant_id", tSysDuty.getTenantId());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment