Browse Source

修正排班计划相关代码

zhongwei
tyty 2 years ago
parent
commit
3e400fd2a5
  1. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/mapper/ImsDutyMainPersonMapper.xml
  2. 95
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyMainServiceImpl.java

2
hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/mapper/ImsDutyMainPersonMapper.xml

@ -10,7 +10,7 @@
<result column="DUTY_DATE" property="dutyDate" jdbcType="DATE"/> <result column="DUTY_DATE" property="dutyDate" jdbcType="DATE"/>
<result column="CLASS_ID" property="classId" jdbcType="BIGINT"/> <result column="CLASS_ID" property="classId" jdbcType="BIGINT"/>
<result column="DUTY_GROUP_ID" property="dutyGroupId" jdbcType="BIGINT"/> <result column="DUTY_GROUP_ID" property="dutyGroupId" jdbcType="BIGINT"/>
<result column="CLASS_NAME" property="className" jdbcType="VARCHAR"/> <result column="DUTY_GROUP_NAME" property="dutyGroupName" jdbcType="VARCHAR"/>
<result column="STATUS" property="status" jdbcType="TINYINT"/> <result column="STATUS" property="status" jdbcType="TINYINT"/>
<result column="REMARK" property="remark" jdbcType="LONGVARCHAR"/> <result column="REMARK" property="remark" jdbcType="LONGVARCHAR"/>
<result column="CREATE_TIME" property="createTime" jdbcType="TIMESTAMP"/> <result column="CREATE_TIME" property="createTime" jdbcType="TIMESTAMP"/>

95
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.cache.UserCache;
import org.springblade.system.user.entity.User; import org.springblade.system.user.entity.User;
import org.springblade.system.user.feign.IUserClient; import org.springblade.system.user.feign.IUserClient;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -518,6 +519,8 @@ public class ImsDutyMainServiceImpl extends BaseServiceImpl<ImsDutyMainMapper, I
if (ObjectUtil.isNotEmpty(imsDutyMainEntity1)) { if (ObjectUtil.isNotEmpty(imsDutyMainEntity1)) {
proDutyMainId = imsDutyMainEntity1.getId().toString(); proDutyMainId = imsDutyMainEntity1.getId().toString();
} }
}
if (StringUtil.isNotBlank(proDutyMainId)) {
imsDutyMainEntity.setPreDutyId(Long.valueOf(proDutyMainId)); imsDutyMainEntity.setPreDutyId(Long.valueOf(proDutyMainId));
} }
if (StringUtil.isNotBlank(personIds)) { if (StringUtil.isNotBlank(personIds)) {
@ -531,6 +534,7 @@ public class ImsDutyMainServiceImpl extends BaseServiceImpl<ImsDutyMainMapper, I
imsDutyMainEntity.setTenantId(AuthUtil.getTenantId()); imsDutyMainEntity.setTenantId(AuthUtil.getTenantId());
imsDutyMainEntityList.add(imsDutyMainEntity); imsDutyMainEntityList.add(imsDutyMainEntity);
proDutyMainId = id == null ? "" : imsDutyMainEntity.getId().toString(); proDutyMainId = id == null ? "" : imsDutyMainEntity.getId().toString();
imsDutyMainEntity1=imsDutyMainEntity;
//同步保存到排班计划-人员表 //同步保存到排班计划-人员表
copyPersonByDutyMain(imsSchedulingVo, managerId, groupName, personEntityList, imsDutyMainEntity, collectPerson); copyPersonByDutyMain(imsSchedulingVo, managerId, groupName, personEntityList, imsDutyMainEntity, collectPerson);
} }
@ -1245,12 +1249,13 @@ public class ImsDutyMainServiceImpl extends BaseServiceImpl<ImsDutyMainMapper, I
if (CollectionUtil.isEmpty(imsDutyMainEntities)) { if (CollectionUtil.isEmpty(imsDutyMainEntities)) {
return R.fail("暂无对应排班计划"); return R.fail("暂无对应排班计划");
} }
List<Long> ids = imsDutyMainEntities.stream().map(ImsDutyMainEntity::getId).collect(Collectors.toList()); List<Long> mainIds = imsDutyMainEntities.stream().map(ImsDutyMainEntity::getId).collect(Collectors.toList());
List<ImsDutyMainPersonEntity> personEntityList = imsDutyMainPersonMapper.selectList(new LambdaQueryWrapper<ImsDutyMainPersonEntity>() {{ List<ImsDutyMainPersonEntity> personEntityList = imsDutyMainPersonMapper.selectList(new LambdaQueryWrapper<ImsDutyMainPersonEntity>() {{
in(ImsDutyMainPersonEntity::getDutyMainId, ids); in(ImsDutyMainPersonEntity::getDutyMainId, mainIds);
}}); }});
if (CollectionUtil.isEmpty(personEntityList)) { if (CollectionUtil.isEmpty(personEntityList)) {
//如果人员计划表中,无值,需要填充对应信息(只有排班-班组,人员计划表才有可能无值) //如果人员计划表中,无值,需要填充对应信息(只有排班-班组,人员计划表才有可能无值)
//对上一个版本做兼容
for (ImsDutyMainEntity imsDutyMainEntity : imsDutyMainEntities) { for (ImsDutyMainEntity imsDutyMainEntity : imsDutyMainEntities) {
String[] dutyPersonIds = imsDutyMainEntity.getDutyPersonIds().split("\\^"); String[] dutyPersonIds = imsDutyMainEntity.getDutyPersonIds().split("\\^");
List<String> personIdlist = Arrays.asList(dutyPersonIds); List<String> personIdlist = Arrays.asList(dutyPersonIds);
@ -1262,23 +1267,20 @@ public class ImsDutyMainServiceImpl extends BaseServiceImpl<ImsDutyMainMapper, I
copyPersonByDutyMain(imsSchedulingVo, imsDutyGroupEntity.getManagerId(), imsDutyGroupEntity.getGroupName(), personEntityList, imsDutyMainEntity, collect); copyPersonByDutyMain(imsSchedulingVo, imsDutyGroupEntity.getManagerId(), imsDutyGroupEntity.getGroupName(), personEntityList, imsDutyMainEntity, collect);
} }
} }
//前期移除,做是否是班组组长的判断 //调出时,做是否是班组组长的判断
List<String> personId = changeDutyMainVo.getPersonId(); List<String> personId = changeDutyMainVo.getPersonId();
HashSet<String> manageIds=new HashSet<>(); HashSet<String> manageIds=new HashSet<>();
HashSet<String> personHashSet=new HashSet<>(); HashSet<String> personHashSet=new HashSet<>();
imsDutyMainEntities.stream().map(s->{ for (ImsDutyMainEntity imsDutyMainEntity : imsDutyMainEntities) {
if (s.getDutyGroupId()!=null){ if (imsDutyMainEntity.getDutyGroupId()!=null){
ImsDutyGroupEntity imsDutyGroupEntity = dutyGroupMapper.selectById(s.getDutyGroupId()); ImsDutyGroupEntity imsDutyGroupEntity = dutyGroupMapper.selectById(imsDutyMainEntity.getDutyGroupId());
manageIds.add(imsDutyGroupEntity.getManagerId().toString()); manageIds.add(imsDutyGroupEntity.getManagerId().toString());
} }
return s;
});
for (ImsDutyMainEntity imsDutyMainEntity : imsDutyMainEntities) {
String[] dutyMainPersonIds = imsDutyMainEntity.getDutyPersonIds().split("\\^"); String[] dutyMainPersonIds = imsDutyMainEntity.getDutyPersonIds().split("\\^");
List<String> personIdlist = new ArrayList<>(Arrays.asList(dutyMainPersonIds)); List<String> personIdlist = new ArrayList<>(Arrays.asList(dutyMainPersonIds));
personHashSet.addAll(personIdlist); personHashSet.addAll(personIdlist);
} }
//调入调出,对人员做重复判断
for (String s : personId) { for (String s : personId) {
if (1==changeDutyMainVo.getType()) { if (1==changeDutyMainVo.getType()) {
if (personHashSet.contains(s)) { if (personHashSet.contains(s)) {
@ -1290,7 +1292,7 @@ public class ImsDutyMainServiceImpl extends BaseServiceImpl<ImsDutyMainMapper, I
} }
} }
} }
//值班组长无法调走
List<String> dutyChargePersonIds = personEntityList.stream().filter(s -> s.getDutyChargePerson()!=null) List<String> dutyChargePersonIds = personEntityList.stream().filter(s -> s.getDutyChargePerson()!=null)
.map(s -> s.getDutyChargePerson().toString()).collect(Collectors.toList()); .map(s -> s.getDutyChargePerson().toString()).collect(Collectors.toList());
manageIds.addAll(dutyChargePersonIds); manageIds.addAll(dutyChargePersonIds);
@ -1303,17 +1305,6 @@ public class ImsDutyMainServiceImpl extends BaseServiceImpl<ImsDutyMainMapper, I
return s; return s;
}); });
List<ImsDutyMainPersonEntity> addPersonEntityList = new ArrayList<>(); List<ImsDutyMainPersonEntity> addPersonEntityList = new ArrayList<>();
List<ImsDutyMainPersonEntity> 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<Long> longList=new ArrayList<>();
List<ImsDutyMainEntity> updateDutyMainEntities = imsDutyMainEntities.stream().map(s -> { List<ImsDutyMainEntity> updateDutyMainEntities = imsDutyMainEntities.stream().map(s -> {
String[] dutyMainPersonIds = s.getDutyPersonIds().split("\\^"); String[] dutyMainPersonIds = s.getDutyPersonIds().split("\\^");
List<String> personIdlist = new ArrayList<>(Arrays.asList(dutyMainPersonIds)); List<String> personIdlist = new ArrayList<>(Arrays.asList(dutyMainPersonIds));
@ -1324,54 +1315,51 @@ public class ImsDutyMainServiceImpl extends BaseServiceImpl<ImsDutyMainMapper, I
} }
String resIds = StringUtils.join(personIdlist, "^"); String resIds = StringUtils.join(personIdlist, "^");
s.setDutyPersonIds(resIds); s.setDutyPersonIds(resIds);
//如果是班组排班,调班之后,则需要转换为灵活排班,加上排班名字
if (s.getDutyGroupId() != null) { if (s.getDutyGroupId() != null) {
s.setDutyGroupId(null); s.setDutyGroupId(null);
} }
long id = IdWorker.getId(s); return s;
for (ImsDutyMainPersonEntity imsDutyMainPersonEntity : personEntityList) { }).collect(Collectors.toList());
if (imsDutyMainPersonEntity.getDutyMainId().equals(s.getId())) { //之前原有的排版-人员表,需要修改的部分
//更换mainID List<ImsDutyMainPersonEntity> updatePersonEntityList= personEntityList.stream().map(sig -> {
imsDutyMainPersonEntity.setDutyMainId(id); 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()) { if(1 == changeDutyMainVo.getType()) {
//根据mainID添加新的排版人员表 for (String addId : personId) {
for (String s1 : personId) { for (Long mainId : mainIds) {
ImsDutyMainPersonEntity entity = new ImsDutyMainPersonEntity(); //copy修改后的数据,
BeanUtil.copy(imsDutyMainPersonEntity, entity); List<ImsDutyMainPersonEntity> collect = updatePersonEntityList.stream().filter(s -> mainId.equals(s.getDutyMainId())).collect(Collectors.toList());
entity.setDutyPerson(Long.valueOf(s1)); ImsDutyMainPersonEntity imsDutyMainPersonEntity=collect.get(0);
ImsDutyMainPersonEntity addEntity = new ImsDutyMainPersonEntity();
BeanUtil.copy(imsDutyMainPersonEntity, addEntity);
addEntity.setDutyPerson(Long.valueOf(addId));
long id1 = IdWorker.getId(imsDutyMainPersonEntity); long id1 = IdWorker.getId(imsDutyMainPersonEntity);
entity.setId(id1); addEntity.setId(id1);
if (!longList.contains(imsDutyMainPersonEntity.getDutyMainId())) { addPersonEntityList.add(addEntity);
addPersonEntityList.add(entity);
longList.add(imsDutyMainPersonEntity.getDutyMainId());
}
}
} }
} }
if (imsDutyMainPersonEntity.getDutyGroupId() != null) { updatePersonEntityList.addAll(addPersonEntityList);
ImsDutyGroupEntity imsDutyGroupEntity = dutyGroupMapper.selectById(imsDutyMainPersonEntity.getDutyGroupId());
imsDutyMainPersonEntity.setDutyGroupName(imsDutyGroupEntity.getGroupName());
imsDutyMainPersonEntity.setDutyGroupId(null);
}
long key = IdWorker.getId(imsDutyMainPersonEntity);
imsDutyMainPersonEntity.setId(key);
} }
s.setId(id);
return s;
}).collect(Collectors.toList());
if (2 == changeDutyMainVo.getType()) { if (2 == changeDutyMainVo.getType()) {
for (String s : personId) { for (String s : personId) {
updatePersonEntityList=updatePersonEntityList.stream().filter( updatePersonEntityList=updatePersonEntityList.stream().filter(
sig -> !sig.getDutyPerson().equals(s)) sig -> !sig.getDutyPerson().equals(s))
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
} else {
updatePersonEntityList.addAll(addPersonEntityList);
} }
this.deleteLogic(ids); //更新排班-班组表,删除排班人员表,再添加排班班组人员表
this.updateBatchById(updateDutyMainEntities);
List<Long> list = personEntityList.stream().map(s -> Long.valueOf(s.getId())).collect(Collectors.toList()); List<Long> list = personEntityList.stream().map(s -> Long.valueOf(s.getId())).collect(Collectors.toList());
iImsDutyMainPersonService.deleteLogic(list); iImsDutyMainPersonService.deleteLogic(list);
this.saveBatch(updateDutyMainEntities);
iImsDutyMainPersonService.saveBatch(updatePersonEntityList); iImsDutyMainPersonService.saveBatch(updatePersonEntityList);
return R.success("修改成功"); return R.success("修改成功");
} }
@ -1594,6 +1582,7 @@ public class ImsDutyMainServiceImpl extends BaseServiceImpl<ImsDutyMainMapper, I
imsDutyMainEntity.setTenantId(AuthUtil.getTenantId()); imsDutyMainEntity.setTenantId(AuthUtil.getTenantId());
imsDutyMainEntityList.add(imsDutyMainEntity); imsDutyMainEntityList.add(imsDutyMainEntity);
proDutyMainId = id == null ? "" : imsDutyMainEntity.getId().toString(); proDutyMainId = id == null ? "" : imsDutyMainEntity.getId().toString();
BeanUtils.copyProperties(imsDutyMainEntity,imsDutyMainEntity1);
} }
} }
} }

Loading…
Cancel
Save