Browse Source

修复:排班计划导出无值班未过滤bug

优化:缺陷新增所属站点
zhongwei
ty 9 months ago
parent
commit
57972fc38a
  1. 14
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/DefectCheckServiceImpl.java
  2. 14
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyMainServiceImpl.java

14
hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/DefectCheckServiceImpl.java

@ -96,8 +96,8 @@ public class DefectCheckServiceImpl extends BaseServiceImpl<OperPhenomenonMapper
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public OperPhenomenonEntity startCheck(OperPhenomenonEntity entity) { public OperPhenomenonEntity startCheck(OperPhenomenonEntity entity) {
if (ObjectUtil.isEmpty(AuthUtil.getDeptId())) { if (ObjectUtil.isEmpty(entity.getCreateDept())) {
throw new ServiceException("获取当前用户机构失败!"); throw new ServiceException("获取缺陷所属机构失败!");
} }
if (ObjectUtil.isNotEmpty(entity.getFinder())&&StringUtils.isBlank(entity.getFinderName())){ if (ObjectUtil.isNotEmpty(entity.getFinder())&&StringUtils.isBlank(entity.getFinderName())){
User user = UserCache.getUser(entity.getFinder()); User user = UserCache.getUser(entity.getFinder());
@ -109,7 +109,7 @@ public class DefectCheckServiceImpl extends BaseServiceImpl<OperPhenomenonMapper
entity.setCreateUserName(AuthUtil.getUserName()); entity.setCreateUserName(AuthUtil.getUserName());
} }
//加锁 //加锁
Boolean lock = redisTemplate.opsForValue().setIfAbsent("SysUserLock" + AuthUtil.getDeptId(), AuthUtil.getDeptId(), 30, TimeUnit.SECONDS); Boolean lock = redisTemplate.opsForValue().setIfAbsent("SysUserLock" + entity.getCreateDept(), entity.getCreateDept(), 30, TimeUnit.SECONDS);
try { try {
if (lock) { if (lock) {
// 步骤1.保存现象 // 步骤1.保存现象
@ -122,7 +122,7 @@ public class DefectCheckServiceImpl extends BaseServiceImpl<OperPhenomenonMapper
last("limit 1"); last("limit 1");
}}); }});
this.startDefectCheckV2(operPhenomenon); this.startDefectCheckV2(operPhenomenon);
redisTemplate.delete("SysUserLock" + AuthUtil.getDeptId()); //删除key,释放锁 redisTemplate.delete("SysUserLock" + entity.getCreateDept()); //删除key,释放锁
} else { } else {
// 加锁失败,抛出异常 // 加锁失败,抛出异常
throw new ServiceException("开启现象流程失败!"); throw new ServiceException("开启现象流程失败!");
@ -134,7 +134,7 @@ public class DefectCheckServiceImpl extends BaseServiceImpl<OperPhenomenonMapper
//抛出异常,以便回滚 //抛出异常,以便回滚
throw new ServiceException("保存现象失败!"+e.getMessage()); throw new ServiceException("保存现象失败!"+e.getMessage());
}finally { }finally {
redisTemplate.delete("SysUserLock" + AuthUtil.getDeptId()); //删除key,释放锁 redisTemplate.delete("SysUserLock" + entity.getCreateDept()); //删除key,释放锁
} }
} }
@ -145,7 +145,7 @@ public class DefectCheckServiceImpl extends BaseServiceImpl<OperPhenomenonMapper
* @return * @return
*/ */
private boolean savePhenomenon(OperPhenomenonEntity entity) { private boolean savePhenomenon(OperPhenomenonEntity entity) {
String deptId = AuthUtil.getDeptId(); String deptId = entity.getCreateDept().toString();
if (StringUtils.isBlank(deptId)) { if (StringUtils.isBlank(deptId)) {
throw new ServiceException("获取当前用户机构失败!"); throw new ServiceException("获取当前用户机构失败!");
} }
@ -180,7 +180,7 @@ public class DefectCheckServiceImpl extends BaseServiceImpl<OperPhenomenonMapper
// 现象更新时间 // 现象更新时间
entity.setUpdateTime(new Date()); entity.setUpdateTime(new Date());
entity.setCreateUser(AuthUtil.getUserId()); entity.setCreateUser(AuthUtil.getUserId());
entity.setCreateDept(Long.valueOf(AuthUtil.getDeptId())); entity.setCreateDept(entity.getCreateDept());
// 现在最后甄别时间 // 现在最后甄别时间
// Date discriminateDeadline = DateUtil.plusHours(entity.getUpdateTime(), DefectConfiguration.discriminateDeadline); // Date discriminateDeadline = DateUtil.plusHours(entity.getUpdateTime(), DefectConfiguration.discriminateDeadline);
// entity.setDiscriminateDeadline(discriminateDeadline); // entity.setDiscriminateDeadline(discriminateDeadline);

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

@ -1591,7 +1591,7 @@ public class ImsDutyMainServiceImpl extends BaseServiceImpl<ImsDutyMainMapper, I
// 获取一天的排班 // 获取一天的排班
List<ImsDutyMainEntity> dutyMainDayList = dutyMainList.stream().filter(var -> dateFormat.format(var.getDutyDate()).equals(dateStr)).collect(Collectors.toList()); List<ImsDutyMainEntity> dutyMainDayList = dutyMainList.stream().filter(var -> dateFormat.format(var.getDutyDate()).equals(dateStr)).collect(Collectors.toList());
List<Long> dayUserIds=new ArrayList<>();
// 循环获取当前日期每个班次组员id // 循环获取当前日期每个班次组员id
for (ImsDutyMainEntity imsDutyMainEntity : dutyMainDayList) { for (ImsDutyMainEntity imsDutyMainEntity : dutyMainDayList) {
ImsDutyMainReportExcel reportExcel = new ImsDutyMainReportExcel(); ImsDutyMainReportExcel reportExcel = new ImsDutyMainReportExcel();
@ -1602,23 +1602,25 @@ public class ImsDutyMainServiceImpl extends BaseServiceImpl<ImsDutyMainMapper, I
} }
reportExcel.setDutyDate(dateStr); reportExcel.setDutyDate(dateStr);
reportExcel.setClassName(imsDutyClass.getClassName() + "(" + imsDutyClass.getStartTime() + " - " + imsDutyClass.getEndTime() + ")"); reportExcel.setClassName(imsDutyClass.getClassName() + "(" + imsDutyClass.getStartTime() + " - " + imsDutyClass.getEndTime() + ")");
List<Long> personIds; List<Long> personIds;
String managerName; String managerName;
if (Func.isNotEmpty(imsDutyMainEntity.getDutyGroupId())) { if (Func.isNotEmpty(imsDutyMainEntity.getDutyGroupId())) {
// 存在分组id需要从分组中获取组长和组员 // 存在分组id需要从分组中获取组长和组员
LambdaQueryWrapper<ImsDutyGroupPEntity> groupPWrapper = new LambdaQueryWrapper(); LambdaQueryWrapper<ImsDutyGroupPEntity> groupPWrapper = new LambdaQueryWrapper();
groupPWrapper.eq(ImsDutyGroupPEntity::getGroupId, imsDutyMainEntity.getDutyGroupId()); groupPWrapper.eq(ImsDutyGroupPEntity::getGroupId, imsDutyMainEntity.getDutyGroupId());
List<ImsDutyGroupPEntity> list = imsDutyGroupPService.list(groupPWrapper); List<ImsDutyGroupPEntity> list = imsDutyGroupPService.list(groupPWrapper);
managerName = deptUserMap.get(deptDutyGroupMap.get(imsDutyMainEntity.getDutyGroupId()).getManagerId()); managerName = deptUserMap.get(deptDutyGroupMap.get(imsDutyMainEntity.getDutyGroupId()).getManagerId());
dayUserIds.addAll(list.stream().map(ImsDutyGroupPEntity::getPersonId).collect(Collectors.toList()));
personIds = list.stream() personIds = list.stream()
// 过滤出组长 // 过滤出组长
.filter(s -> !s.getPersonId().equals(deptDutyGroupMap.get(imsDutyMainEntity.getDutyGroupId()).getManagerId())) .filter(s -> !s.getPersonId().equals(deptDutyGroupMap.get(imsDutyMainEntity.getDutyGroupId()).getManagerId()))
.map(ImsDutyGroupPEntity::getPersonId).collect(Collectors.toList()); .map(ImsDutyGroupPEntity::getPersonId).collect(Collectors.toList());
} else { } else {
// 不存在分组id从排班人员中获取组长和组员 // 不存在分组id从排班人员中获取组长和组员
List<ImsDutyMainPersonEntity> personList = deptPersonList.stream().filter(var -> var.getDutyMainId().equals(imsDutyMainEntity.getId())).collect(Collectors.toList()); List<ImsDutyMainPersonEntity> personList = deptPersonList.stream().filter(var -> var.getDutyMainId().equals(imsDutyMainEntity.getId())).collect(Collectors.toList());
dayUserIds.addAll( personList.stream().map(ImsDutyMainPersonEntity::getDutyPerson).collect(Collectors.toList()));
managerName = deptUserMap.get(personList.get(0).getDutyChargePerson()); managerName = deptUserMap.get(personList.get(0).getDutyChargePerson());
personIds = personList.stream().filter(s -> !s.getDutyPerson().equals(personList.get(0).getDutyChargePerson())).map(ImsDutyMainPersonEntity::getDutyPerson).collect(Collectors.toList()); personIds = personList.stream().filter(s -> !s.getDutyPerson().equals(personList.get(0).getDutyChargePerson())).map(ImsDutyMainPersonEntity::getDutyPerson).collect(Collectors.toList());
} }
@ -1628,8 +1630,6 @@ public class ImsDutyMainServiceImpl extends BaseServiceImpl<ImsDutyMainMapper, I
for (int j = 0; j < personIds.size(); j++) { for (int j = 0; j < personIds.size(); j++) {
Long userId = personIds.get(j); Long userId = personIds.get(j);
String userName = deptUserMap.get(userId); String userName = deptUserMap.get(userId);
// 把排班的组员从休息名单中移除
restUserList.removeIf(user -> user.getId().equals(userId));
if (ObjectUtil.isNotEmpty(userName)) { if (ObjectUtil.isNotEmpty(userName)) {
if (j == personIds.size() - 1) { if (j == personIds.size() - 1) {
personNames += userName; personNames += userName;
@ -1648,6 +1648,10 @@ public class ImsDutyMainServiceImpl extends BaseServiceImpl<ImsDutyMainMapper, I
restReportExcel.setClassName("休息"); restReportExcel.setClassName("休息");
restReportExcel.setManagerName("无班组长"); restReportExcel.setManagerName("无班组长");
String personNames = ""; String personNames = "";
// 把排班的组员从休息名单中移除
for (Long userId : dayUserIds) {
restUserList.removeIf(user -> user.getId().equals(userId));
}
// 获取休息组员的名称 // 获取休息组员的名称
for (int j = 0; j < restUserList.size(); j++) { for (int j = 0; j < restUserList.size(); j++) {
User user = restUserList.get(j); User user = restUserList.get(j);

Loading…
Cancel
Save