|
@ -4,17 +4,24 @@ import com.alibaba.fastjson.JSONObject; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
|
|
import com.digiwin.app.service.DWEAIResult; |
|
|
import com.digiwin.app.service.DWEAIResult; |
|
|
|
|
|
import com.digiwin.athena.app.infra.common.enums.OptionEnums; |
|
|
import com.digiwin.athena.app.infra.common.enums.TabStatusEnums; |
|
|
import com.digiwin.athena.app.infra.common.enums.TabStatusEnums; |
|
|
|
|
|
import com.digiwin.athena.app.infra.dto.staff.StaffDTO; |
|
|
import com.digiwin.athena.app.infra.entity.StaffEntity; |
|
|
import com.digiwin.athena.app.infra.entity.StaffEntity; |
|
|
import com.digiwin.athena.app.infra.repository.StaffRepository; |
|
|
import com.digiwin.athena.app.infra.repository.StaffRepository; |
|
|
import com.digiwin.athena.app.infra.service.StaffService; |
|
|
import com.digiwin.athena.app.infra.service.StaffService; |
|
|
|
|
|
import com.digiwin.athena.opt.common.eai.EAIRequest; |
|
|
import com.digiwin.athena.opt.common.eai.EAIUtil; |
|
|
import com.digiwin.athena.opt.common.eai.EAIUtil; |
|
|
import com.digiwin.athena.opt.common.eai.service.AbsEAIService; |
|
|
import com.digiwin.athena.opt.common.eai.service.AbsEAIService; |
|
|
import com.digiwin.athena.opt.common.security.SecurityUtil; |
|
|
import com.digiwin.athena.opt.common.security.SecurityUtil; |
|
|
|
|
|
import lombok.extern.log4j.Log4j2; |
|
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.util.CollectionUtils; |
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
|
|
import org.springframework.util.StringUtils; |
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
import javax.annotation.Resource; |
|
|
|
|
|
import java.util.HashMap; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
import java.util.Map; |
|
|
import java.util.Map; |
|
|
import java.util.stream.Collectors; |
|
|
import java.util.stream.Collectors; |
|
@ -23,6 +30,8 @@ import java.util.stream.Collectors; |
|
|
* @Auther: zhenggl |
|
|
* @Auther: zhenggl |
|
|
* @Date: 2023/4/28 |
|
|
* @Date: 2023/4/28 |
|
|
*/ |
|
|
*/ |
|
|
|
|
|
@Service |
|
|
|
|
|
@Log4j2 |
|
|
public class StaffGetEAIService extends AbsEAIService { |
|
|
public class StaffGetEAIService extends AbsEAIService { |
|
|
|
|
|
|
|
|
@Resource |
|
|
@Resource |
|
@ -39,22 +48,62 @@ public class StaffGetEAIService extends AbsEAIService { |
|
|
@Override |
|
|
@Override |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
public DWEAIResult execute(Map<String, String> headers, String messageBody) throws Exception { |
|
|
public DWEAIResult execute(Map<String, String> headers, String messageBody) throws Exception { |
|
|
//查询所有tab_status=0的数据然后把他们全部修改为1 |
|
|
|
|
|
LambdaQueryWrapper<StaffEntity> lmq = new LambdaQueryWrapper<>(); |
|
|
|
|
|
lmq.eq(StaffEntity::getTenantSid, SecurityUtil.getUserProfile().getTenantSid()); |
|
|
|
|
|
lmq.eq(StaffEntity::getTabStatus, TabStatusEnums.NOSET.getValue()); |
|
|
|
|
|
List<StaffEntity> staffEntities = staffRepository.selectList(lmq); |
|
|
|
|
|
if (!CollectionUtils.isEmpty(staffEntities)){ |
|
|
|
|
|
List<Long> idList = staffEntities.stream().map(StaffEntity::getId).collect(Collectors.toList()); |
|
|
|
|
|
LambdaUpdateWrapper<StaffEntity> lmu = new LambdaUpdateWrapper<>(); |
|
|
|
|
|
lmu.set(StaffEntity::getTabStatus,TabStatusEnums.PENDING); |
|
|
|
|
|
lmu.in(StaffEntity::getId,idList); |
|
|
|
|
|
staffService.update(lmu); |
|
|
|
|
|
//修改查询到的参数 |
|
|
|
|
|
staffEntities.forEach(item ->{ |
|
|
|
|
|
item.setTabStatus(TabStatusEnums.PENDING.getValue()); |
|
|
|
|
|
|
|
|
//反序列化字段 |
|
|
|
|
|
EAIRequest request = new EAIRequest(messageBody); |
|
|
|
|
|
String option = request.getObject("option", String.class); |
|
|
|
|
|
//为空走侦测逻辑 |
|
|
|
|
|
if (StringUtils.isEmpty(option)) { |
|
|
|
|
|
//查询所有tab_status=0的数据然后把他们全部修改为1 |
|
|
|
|
|
LambdaQueryWrapper<StaffEntity> lmq = new LambdaQueryWrapper<>(); |
|
|
|
|
|
lmq.eq(StaffEntity::getTenantSid, SecurityUtil.getUserProfile().getTenantSid()); |
|
|
|
|
|
lmq.eq(StaffEntity::getTabStatus, TabStatusEnums.NOSET.getValue()); |
|
|
|
|
|
List<StaffEntity> staffEntities = staffRepository.selectList(lmq); |
|
|
|
|
|
if (!CollectionUtils.isEmpty(staffEntities)) { |
|
|
|
|
|
List<Long> idList = staffEntities.stream().map(StaffEntity::getId).collect(Collectors.toList()); |
|
|
|
|
|
LambdaUpdateWrapper<StaffEntity> lmu = new LambdaUpdateWrapper<>(); |
|
|
|
|
|
lmu.set(StaffEntity::getTabStatus, TabStatusEnums.PENDING); |
|
|
|
|
|
lmu.in(StaffEntity::getId, idList); |
|
|
|
|
|
staffService.update(lmu); |
|
|
|
|
|
//修改查询到的参数 |
|
|
|
|
|
staffEntities.forEach(item -> { |
|
|
|
|
|
item.setTabStatus(TabStatusEnums.PENDING.getValue()); |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
return EAIUtil.buildEAIResult(new JSONObject().fluentPut("wait_register_personnel", staffEntities)); |
|
|
|
|
|
} else if (OptionEnums.TASK.equals(option)) { |
|
|
|
|
|
List<StaffDTO> staffDTOS = request.getObject("wait_register_personnel", StaffUtil.LIST_DTO_STAFF); |
|
|
|
|
|
LambdaQueryWrapper<StaffEntity> lmq = new LambdaQueryWrapper<>(); |
|
|
|
|
|
lmq.eq(StaffEntity::getTenantSid, SecurityUtil.getUserProfile().getTenantSid()); |
|
|
|
|
|
lmq.and(queryWrapperInner -> { |
|
|
|
|
|
for (StaffDTO staffDTO : staffDTOS) { |
|
|
|
|
|
queryWrapperInner.or( |
|
|
|
|
|
wrapper -> wrapper |
|
|
|
|
|
.eq(!StringUtils.isEmpty(staffDTO.getTabStatus()), StaffEntity::getTabStatus, staffDTO.getTabStatus()) |
|
|
|
|
|
.eq(!StringUtils.isEmpty(staffDTO.getId()), StaffEntity::getId, staffDTO.getId()) |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
}); |
|
|
}); |
|
|
|
|
|
List<StaffEntity> staffEntities = staffRepository.selectList(lmq); |
|
|
|
|
|
return EAIUtil.buildEAIResult(new JSONObject().fluentPut("wait_register_personnel", staffEntities)); |
|
|
|
|
|
} else if (OptionEnums.BASIC.equals(option)) { |
|
|
|
|
|
List<StaffDTO> staffDTOS = request.getObject("wait_register_personnel", StaffUtil.LIST_DTO_STAFF); |
|
|
|
|
|
LambdaQueryWrapper<StaffEntity> lmq = new LambdaQueryWrapper<>(); |
|
|
|
|
|
lmq.eq(StaffEntity::getTenantSid, SecurityUtil.getUserProfile().getTenantSid()); |
|
|
|
|
|
lmq.and(queryWrapperInner -> { |
|
|
|
|
|
for (StaffDTO staffDTO : staffDTOS) { |
|
|
|
|
|
queryWrapperInner.or( |
|
|
|
|
|
wrapper -> wrapper |
|
|
|
|
|
.eq(!StringUtils.isEmpty(staffDTO.getEmployeeNo()), StaffEntity::getEmployeeNo, staffDTO.getEmployeeNo()) |
|
|
|
|
|
.eq(!StringUtils.isEmpty(staffDTO.getEmployeeName()), StaffEntity::getEmployeeName, staffDTO.getEmployeeName()) |
|
|
|
|
|
.eq(!StringUtils.isEmpty(staffDTO.getEnEmployeeName()), StaffEntity::getEnEmployeeName, staffDTO.getEnEmployeeName()) |
|
|
|
|
|
.eq(!StringUtils.isEmpty(staffDTO.getEmail()), StaffEntity::getEmail, staffDTO.getEmail()) |
|
|
|
|
|
.eq(!StringUtils.isEmpty(staffDTO.getMobileNo()), StaffEntity::getMobileNo, staffDTO.getMobileNo()) |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
List<StaffEntity> staffEntities = staffRepository.selectList(lmq); |
|
|
|
|
|
return EAIUtil.buildEAIResult(new JSONObject().fluentPut("wait_register_personnel", staffEntities)); |
|
|
} |
|
|
} |
|
|
return EAIUtil.buildEAIResult(new JSONObject().fluentPut("wait_register_personnel",staffEntities)); |
|
|
|
|
|
|
|
|
return EAIUtil.buildEAIResult(new HashMap<>()); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |