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