From 3e400fd2a5cff19a6516609ceccd4a8ba2035f9d Mon Sep 17 00:00:00 2001 From: tyty Date: Thu, 13 Apr 2023 19:48:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E6=8E=92=E7=8F=AD=E8=AE=A1?= =?UTF-8?q?=E5=88=92=E7=9B=B8=E5=85=B3=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../duty/mapper/ImsDutyMainPersonMapper.xml | 2 +- .../duty/service/impl/ImsDutyMainServiceImpl.java | 101 +++++++++------------ 2 files changed, 46 insertions(+), 57 deletions(-) diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/mapper/ImsDutyMainPersonMapper.xml b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/mapper/ImsDutyMainPersonMapper.xml index a544f90..d97abfe 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/mapper/ImsDutyMainPersonMapper.xml +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/mapper/ImsDutyMainPersonMapper.xml @@ -10,7 +10,7 @@ - + diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyMainServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyMainServiceImpl.java index 8bb0812..77a676b 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyMainServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyMainServiceImpl.java @@ -31,6 +31,7 @@ import org.springblade.core.tool.utils.*; import org.springblade.system.user.cache.UserCache; import org.springblade.system.user.entity.User; import org.springblade.system.user.feign.IUserClient; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -518,6 +519,8 @@ public class ImsDutyMainServiceImpl extends BaseServiceImpl ids = imsDutyMainEntities.stream().map(ImsDutyMainEntity::getId).collect(Collectors.toList()); + List mainIds = imsDutyMainEntities.stream().map(ImsDutyMainEntity::getId).collect(Collectors.toList()); List personEntityList = imsDutyMainPersonMapper.selectList(new LambdaQueryWrapper() {{ - in(ImsDutyMainPersonEntity::getDutyMainId, ids); + in(ImsDutyMainPersonEntity::getDutyMainId, mainIds); }}); if (CollectionUtil.isEmpty(personEntityList)) { //如果人员计划表中,无值,需要填充对应信息(只有排班-班组,人员计划表才有可能无值) + //对上一个版本做兼容 for (ImsDutyMainEntity imsDutyMainEntity : imsDutyMainEntities) { String[] dutyPersonIds = imsDutyMainEntity.getDutyPersonIds().split("\\^"); List personIdlist = Arrays.asList(dutyPersonIds); @@ -1262,23 +1267,20 @@ public class ImsDutyMainServiceImpl extends BaseServiceImpl personId = changeDutyMainVo.getPersonId(); HashSet manageIds=new HashSet<>(); HashSet personHashSet=new HashSet<>(); - imsDutyMainEntities.stream().map(s->{ - if (s.getDutyGroupId()!=null){ - ImsDutyGroupEntity imsDutyGroupEntity = dutyGroupMapper.selectById(s.getDutyGroupId()); + for (ImsDutyMainEntity imsDutyMainEntity : imsDutyMainEntities) { + if (imsDutyMainEntity.getDutyGroupId()!=null){ + ImsDutyGroupEntity imsDutyGroupEntity = dutyGroupMapper.selectById(imsDutyMainEntity.getDutyGroupId()); manageIds.add(imsDutyGroupEntity.getManagerId().toString()); } - return s; - }); - for (ImsDutyMainEntity imsDutyMainEntity : imsDutyMainEntities) { String[] dutyMainPersonIds = imsDutyMainEntity.getDutyPersonIds().split("\\^"); List personIdlist = new ArrayList<>(Arrays.asList(dutyMainPersonIds)); personHashSet.addAll(personIdlist); - } + //调入调出,对人员做重复判断 for (String s : personId) { if (1==changeDutyMainVo.getType()) { if (personHashSet.contains(s)) { @@ -1290,7 +1292,7 @@ public class ImsDutyMainServiceImpl extends BaseServiceImpl dutyChargePersonIds = personEntityList.stream().filter(s -> s.getDutyChargePerson()!=null) .map(s -> s.getDutyChargePerson().toString()).collect(Collectors.toList()); manageIds.addAll(dutyChargePersonIds); @@ -1303,17 +1305,6 @@ public class ImsDutyMainServiceImpl extends BaseServiceImpl addPersonEntityList = new ArrayList<>(); - List updatePersonEntityList= personEntityList.stream().map(sig -> { - if (sig.getDutyGroupId() != null) { - ImsDutyGroupEntity imsDutyGroupEntity = dutyGroupMapper.selectById(sig.getDutyGroupId()); - sig.setDutyGroupName(imsDutyGroupEntity.getGroupName()); - sig.setDutyGroupId(null); - } - long id = IdWorker.getId(sig); - sig.setId(id); - return sig; - }).collect(Collectors.toList()); - List longList=new ArrayList<>(); List updateDutyMainEntities = imsDutyMainEntities.stream().map(s -> { String[] dutyMainPersonIds = s.getDutyPersonIds().split("\\^"); List personIdlist = new ArrayList<>(Arrays.asList(dutyMainPersonIds)); @@ -1324,54 +1315,51 @@ public class ImsDutyMainServiceImpl extends BaseServiceImpl updatePersonEntityList= personEntityList.stream().map(sig -> { + if (sig.getDutyGroupId() != null) { + ImsDutyGroupEntity imsDutyGroupEntity = dutyGroupMapper.selectById(sig.getDutyGroupId()); + sig.setDutyGroupName(imsDutyGroupEntity.getGroupName()); + sig.setDutyGroupId(null); + } + long id = IdWorker.getId(sig); + sig.setId(id); + return sig; + }).collect(Collectors.toList()); + //如果是添加,填充对应人员的排版人员表 + if(1 == changeDutyMainVo.getType()) { + for (String addId : personId) { + for (Long mainId : mainIds) { + //copy修改后的数据, + List collect = updatePersonEntityList.stream().filter(s -> mainId.equals(s.getDutyMainId())).collect(Collectors.toList()); + ImsDutyMainPersonEntity imsDutyMainPersonEntity=collect.get(0); + ImsDutyMainPersonEntity addEntity = new ImsDutyMainPersonEntity(); + BeanUtil.copy(imsDutyMainPersonEntity, addEntity); + addEntity.setDutyPerson(Long.valueOf(addId)); + long id1 = IdWorker.getId(imsDutyMainPersonEntity); + addEntity.setId(id1); + addPersonEntityList.add(addEntity); + } + } + updatePersonEntityList.addAll(addPersonEntityList); + } if (2 == changeDutyMainVo.getType()) { for (String s : personId) { updatePersonEntityList=updatePersonEntityList.stream().filter( sig -> !sig.getDutyPerson().equals(s)) .collect(Collectors.toList()); } - } else { - updatePersonEntityList.addAll(addPersonEntityList); } - this.deleteLogic(ids); + //更新排班-班组表,删除排班人员表,再添加排班班组人员表 + this.updateBatchById(updateDutyMainEntities); List list = personEntityList.stream().map(s -> Long.valueOf(s.getId())).collect(Collectors.toList()); iImsDutyMainPersonService.deleteLogic(list); - this.saveBatch(updateDutyMainEntities); iImsDutyMainPersonService.saveBatch(updatePersonEntityList); return R.success("修改成功"); } @@ -1594,6 +1582,7 @@ public class ImsDutyMainServiceImpl extends BaseServiceImpl