Browse Source

排班计划bug修复

zhongwei
tyty 1 year ago
parent
commit
cc80962a0a
  1. 2
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/duty/entity/ImsDutyMainPersonEntity.java
  2. 4
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/mapper/ImsDutyMainMapper.java
  3. 10
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/mapper/ImsDutyMainMapper.xml
  4. 70
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyMainServiceImpl.java

2
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/duty/entity/ImsDutyMainPersonEntity.java

@ -1,6 +1,5 @@
package com.hnac.hzims.operational.duty.entity; package com.hnac.hzims.operational.duty.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
@ -65,7 +64,6 @@ public class ImsDutyMainPersonEntity extends TenantEntity {
/** /**
* 值班班组名称 * 值班班组名称
*/ */
@TableField(exist=false)
@ApiModelProperty(value = "值班班组名称") @ApiModelProperty(value = "值班班组名称")
private String dutyGroupName; private String dutyGroupName;
/** /**

4
hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/mapper/ImsDutyMainMapper.java

@ -1,10 +1,9 @@
package com.hnac.hzims.operational.duty.mapper; package com.hnac.hzims.operational.duty.mapper;
import com.hnac.hzims.operational.duty.entity.ImsDutyMainEntity;
import com.hnac.hzims.operational.duty.vo.*; import com.hnac.hzims.operational.duty.vo.*;
import io.swagger.annotations.Api;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.springblade.core.datascope.annotation.UserDataAuth; import org.springblade.core.datascope.annotation.UserDataAuth;
import com.hnac.hzims.operational.duty.entity.ImsDutyMainEntity;
import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper;
import java.util.List; import java.util.List;
@ -40,6 +39,7 @@ public interface ImsDutyMainMapper extends UserDataScopeBaseMapper<ImsDutyMainEn
ImsDutyMainEntity selectMainByIdOne(Long id); ImsDutyMainEntity selectMainByIdOne(Long id);
void deleteByUserId(List<Long> list);
void deleteDate(String date); void deleteDate(String date);
@UserDataAuth @UserDataAuth

10
hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/mapper/ImsDutyMainMapper.xml

@ -47,7 +47,15 @@
and id !=#{id} and id !=#{id}
</if> </if>
</select> </select>
<delete id="deleteByUserId" >
delete from hz_ims_duty_main where is_deleted = 0
<if test="list != null and list.size > 0">
and id in
<foreach collection="list" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
</delete>
<select id="selectByDateList" resultType="com.hnac.hzims.operational.duty.vo.ImsSchedulingVo"> <select id="selectByDateList" resultType="com.hnac.hzims.operational.duty.vo.ImsSchedulingVo">
SELECT SELECT
DM.ID AS id, DM.ID AS id,

70
hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyMainServiceImpl.java

@ -780,6 +780,15 @@ public class ImsDutyMainServiceImpl extends BaseServiceImpl<ImsDutyMainMapper, I
collect = collect.stream().map(s -> { collect = collect.stream().map(s -> {
//灵活排班把班组名称拼接成人员名称 //灵活排班把班组名称拼接成人员名称
if (s.getGroupId() == null) { if (s.getGroupId() == null) {
ImsDutyMainPersonEntity imsDutyMainPersonEntity = imsDutyMainPersonMapper.selectOne(new LambdaQueryWrapper<ImsDutyMainPersonEntity>() {{
eq(ImsDutyMainPersonEntity::getDutyMainId, s.getId());
last(" limit 1");
}});
//如果person的表中有班组名称,则直接取
if (ObjectUtil.isNotEmpty(imsDutyMainPersonEntity) && imsDutyMainPersonEntity.getDutyGroupName() != null) {
s.setName(imsDutyMainPersonEntity.getDutyGroupName());
} else {
//否则,拼接对应人员
String[] split = s.getDutyPersonIds().split("\\^"); String[] split = s.getDutyPersonIds().split("\\^");
if (null != split && split.length > 0) { if (null != split && split.length > 0) {
for (int j = 0; j < split.length; j++) { for (int j = 0; j < split.length; j++) {
@ -793,6 +802,7 @@ public class ImsDutyMainServiceImpl extends BaseServiceImpl<ImsDutyMainMapper, I
} }
} }
} }
}
} else { } else {
ImsDutyGroupEntity imsDutyGroupEntity = dutyGroupMapper.selectById(s.getGroupId()); ImsDutyGroupEntity imsDutyGroupEntity = dutyGroupMapper.selectById(s.getGroupId());
s.setName(s.getName() + imsDutyGroupEntity.getGroupName()); s.setName(s.getName() + imsDutyGroupEntity.getGroupName());
@ -867,11 +877,11 @@ public class ImsDutyMainServiceImpl extends BaseServiceImpl<ImsDutyMainMapper, I
if (null != split && split.length > 0) { if (null != split && split.length > 0) {
for (String s : split) { for (String s : split) {
ImsDutyMainVO vo = new ImsDutyMainVO(); ImsDutyMainVO vo = new ImsDutyMainVO();
User user = UserCache.getUser(Long.valueOf(s)); R<User> user = userClient.userInfoById(Long.valueOf(s));
if (ObjectUtil.isNotEmpty(user)) { if (user.isSuccess() && ObjectUtil.isNotEmpty(user.getData())) {
vo.setUserId(s); vo.setUserId(s);
if (ObjectUtil.isNotEmpty(user)) { if (ObjectUtil.isNotEmpty(user.getData().getName())) {
vo.setUserName(user.getName()); vo.setUserName(user.getData().getName());
} }
vo.setId(id); vo.setId(id);
list.add(vo); list.add(vo);
@ -891,7 +901,7 @@ public class ImsDutyMainServiceImpl extends BaseServiceImpl<ImsDutyMainMapper, I
managerId = imsDutyMainPersonEntity.getDutyChargePerson(); managerId = imsDutyMainPersonEntity.getDutyChargePerson();
} }
list = list.stream().map(s -> { list = list.stream().map(s -> {
if (s.getUserId().equals(managerId.toString())) { if (managerId.toString().equals(s.getUserId())) {
s.setUserName(s.getUserName() + "(值班组组长)"); s.setUserName(s.getUserName() + "(值班组组长)");
} }
return s; return s;
@ -1260,6 +1270,7 @@ public class ImsDutyMainServiceImpl extends BaseServiceImpl<ImsDutyMainMapper, I
List<ImsDutyMainPersonEntity> personEntityList = imsDutyMainPersonMapper.selectList(new LambdaQueryWrapper<ImsDutyMainPersonEntity>() {{ List<ImsDutyMainPersonEntity> personEntityList = imsDutyMainPersonMapper.selectList(new LambdaQueryWrapper<ImsDutyMainPersonEntity>() {{
in(ImsDutyMainPersonEntity::getDutyMainId, mainIds); in(ImsDutyMainPersonEntity::getDutyMainId, mainIds);
}}); }});
List<Long> list = personEntityList.stream().map(s -> Long.valueOf(s.getId())).collect(Collectors.toList());
if (CollectionUtil.isEmpty(personEntityList)) { if (CollectionUtil.isEmpty(personEntityList)) {
//如果人员计划表中,无值,需要填充对应信息(只有排班-班组,人员计划表才有可能无值) //如果人员计划表中,无值,需要填充对应信息(只有排班-班组,人员计划表才有可能无值)
//对上一个版本做兼容 //对上一个版本做兼容
@ -1303,14 +1314,35 @@ 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);
personId.stream().map(s -> { for (String s : personId) {
for (String manageId : manageIds) { if (manageIds.contains(s)) {
if (s.equals(manageId)){
return R.fail("值班组组长无法修改排班"); return R.fail("值班组组长无法修改排班");
} }
} }
return s; // personId.stream().map(s -> {
}); // for (String manageId : manageIds) {
// if (s.equals(manageId)){
// return R.fail("值班组组长无法修改排班");
// }
// }
// return s;
// });
//之前原有的排版-人员表,需要修改的部分
List<ImsDutyMainPersonEntity> updatePersonEntityList = personEntityList.stream().map(sig -> {
//如果是班组排班,灵活调动后,对应的班组名称保留,但是不再有groupId
List<Long> collect = imsDutyMainEntities.stream().filter(s -> s.getId().equals(sig.getDutyMainId())).map(s -> s.getDutyGroupId()).collect(Collectors.toList());
if (Func.isNotEmpty(collect)) {
ImsDutyGroupEntity imsDutyGroupEntity = dutyGroupMapper.selectById(collect.get(0));
if (ObjectUtil.isNotEmpty(imsDutyGroupEntity)) {
sig.setDutyGroupName(imsDutyGroupEntity.getGroupName());
sig.setDutyGroupId(null);
}
}
long id = IdWorker.getId(sig);
sig.setId(id);
return sig;
}).collect(Collectors.toList());
List<ImsDutyMainPersonEntity> addPersonEntityList = new ArrayList<>(); List<ImsDutyMainPersonEntity> addPersonEntityList = 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("\\^");
@ -1328,18 +1360,7 @@ public class ImsDutyMainServiceImpl extends BaseServiceImpl<ImsDutyMainMapper, I
} }
return s; return s;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
//之前原有的排版-人员表,需要修改的部分 //如果是添加,填充对应人员排版表
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());
//如果是添加,填充对应人员的排版人员表
if (1 == changeDutyMainVo.getType()) { if (1 == changeDutyMainVo.getType()) {
for (String addId : personId) { for (String addId : personId) {
for (Long mainId : mainIds) { for (Long mainId : mainIds) {
@ -1364,8 +1385,9 @@ public class ImsDutyMainServiceImpl extends BaseServiceImpl<ImsDutyMainMapper, I
} }
} }
//更新排班-班组表,删除排班人员表,再添加排班班组人员表 //更新排班-班组表,删除排班人员表,再添加排班班组人员表
this.updateBatchById(updateDutyMainEntities); List<Long> updateDutyMainIds = updateDutyMainEntities.stream().map(s -> Long.valueOf(s.getId())).collect(Collectors.toList());
List<Long> list = personEntityList.stream().map(s -> Long.valueOf(s.getId())).collect(Collectors.toList()); this.baseMapper.deleteByUserId(updateDutyMainIds);
this.saveBatch(updateDutyMainEntities);
iImsDutyMainPersonService.deleteLogic(list); iImsDutyMainPersonService.deleteLogic(list);
iImsDutyMainPersonService.saveBatch(updatePersonEntityList); iImsDutyMainPersonService.saveBatch(updatePersonEntityList);
return R.success("修改成功"); return R.success("修改成功");

Loading…
Cancel
Save