@ -0,0 +1,26 @@ | |||
package com.digiwin.athena.app.infra.common.enums; | |||
/** | |||
* @Auther: zhenggl | |||
* @Date: 2023/4/28 | |||
*/ | |||
public enum StatusEnums { | |||
//待报道 | |||
TOBEREPORTED(1), | |||
//已完成 | |||
REPORTED(2), | |||
//未报道 | |||
NOSHOW(3); | |||
private final Integer value; | |||
StatusEnums(Integer value) { | |||
this.value = value; | |||
} | |||
public Integer getValue() { | |||
return value; | |||
} | |||
} |
@ -0,0 +1,25 @@ | |||
package com.digiwin.athena.app.infra.common.enums; | |||
/** | |||
* @Auther: zhenggl | |||
* @Date: 2023/4/28 | |||
*/ | |||
public enum TabStatusEnums { | |||
//未设定 | |||
NOSET(0), | |||
//待处理 | |||
PENDING(1), | |||
//已完成 | |||
COMPLETED(2); | |||
private final Integer value; | |||
TabStatusEnums(Integer value) { | |||
this.value = value; | |||
} | |||
public Integer getValue() { | |||
return value; | |||
} | |||
} |
@ -0,0 +1,66 @@ | |||
package com.digiwin.athena.app.infra.common.utils; | |||
import com.digiwin.app.container.exceptions.DWRuntimeException; | |||
import net.sf.cglib.beans.BeanCopier; | |||
import net.sf.cglib.beans.BeanMap; | |||
import org.springframework.objenesis.ObjenesisStd; | |||
import java.util.ArrayList; | |||
import java.util.Collections; | |||
import java.util.List; | |||
import java.util.Map; | |||
import java.util.concurrent.ConcurrentHashMap; | |||
public final class BeanCopyUtil { | |||
private BeanCopyUtil() { | |||
} | |||
private static ThreadLocal<ObjenesisStd> objenesisStdThreadLocal = ThreadLocal.withInitial(ObjenesisStd::new); | |||
private static ConcurrentHashMap<Class<?>, ConcurrentHashMap<Class<?>, BeanCopier>> cache = new ConcurrentHashMap<>(); | |||
public static <T> T copy(Object source, Class<T> target) { | |||
return copy(source, objenesisStdThreadLocal.get().newInstance(target)); | |||
} | |||
public static <T> T copy(Object source, T target) { | |||
BeanCopier beanCopier = getCacheBeanCopier(source.getClass(), target.getClass()); | |||
beanCopier.copy(source, target, null); | |||
return target; | |||
} | |||
public static <T> List<T> copyList(List<?> sources, Class<T> target) { | |||
if (sources.isEmpty()) { | |||
return Collections.emptyList(); | |||
} | |||
ArrayList<T> list = new ArrayList<>(sources.size()); | |||
ObjenesisStd objenesisStd = objenesisStdThreadLocal.get(); | |||
for (Object source : sources) { | |||
if (source == null) { | |||
throw new DWRuntimeException("转换异常"); | |||
} | |||
T newInstance = objenesisStd.newInstance(target); | |||
BeanCopier beanCopier = getCacheBeanCopier(source.getClass(), target); | |||
beanCopier.copy(source, newInstance, null); | |||
list.add(newInstance); | |||
} | |||
return list; | |||
} | |||
public static <T> T mapToBean(Map<?, ?> source, Class<T> target) { | |||
T bean = objenesisStdThreadLocal.get().newInstance(target); | |||
BeanMap beanMap = BeanMap.create(bean); | |||
beanMap.putAll(source); | |||
return bean; | |||
} | |||
public static <T> Map<?, ?> beanToMap(T source) { | |||
return BeanMap.create(source); | |||
} | |||
private static <S, T> BeanCopier getCacheBeanCopier(Class<S> source, Class<T> target) { | |||
ConcurrentHashMap<Class<?>, BeanCopier> copierConcurrentHashMap = cache.computeIfAbsent(source, aClass -> new ConcurrentHashMap<>(16)); | |||
return copierConcurrentHashMap.computeIfAbsent(target, aClass -> BeanCopier.create(source, target, false)); | |||
} | |||
} |
@ -0,0 +1,105 @@ | |||
package com.digiwin.athena.app.infra.common.utils; | |||
import com.alibaba.fastjson.JSONObject; | |||
import com.fasterxml.jackson.core.type.TypeReference; | |||
import com.fasterxml.jackson.databind.JavaType; | |||
import com.fasterxml.jackson.databind.ObjectMapper; | |||
import lombok.extern.log4j.Log4j; | |||
import org.apache.commons.collections.MapUtils; | |||
import org.apache.commons.lang3.StringUtils; | |||
import java.io.IOException; | |||
import java.util.ArrayList; | |||
import java.util.HashMap; | |||
import java.util.List; | |||
import java.util.Map; | |||
/** | |||
* @Author: xieps | |||
* @Date: 2023/3/21 13:49 | |||
* @Version 1.0 | |||
* @Description | |||
*/ | |||
@Log4j | |||
public class TransferUtil { | |||
public static final ObjectMapper objectMapper = new ObjectMapper(); | |||
public static <T> List<T> string2List(String messageBody, Class<T> clazz, String key) { | |||
// 获取请求参数 | |||
JSONObject parameter = TransferUtil.getAthenaParameter(messageBody); | |||
return TransferUtil.convertString2List(parameter.toJSONString(), key, clazz); | |||
} | |||
/** | |||
* String 转model List | |||
* @param param | |||
* @param key | |||
* @param clazz | |||
* @param <T> | |||
* @return | |||
*/ | |||
public static <T> List<T> convertString2List(String param, String key, Class<T> clazz) { | |||
Map<String, Object> paramMap = str2Map(param); | |||
return getMapTs(paramMap, key, clazz); | |||
} | |||
/** | |||
* String 转 map | |||
* | |||
* @param param | |||
* @return | |||
* @throws Exception | |||
*/ | |||
public static Map<String, Object> str2Map(String param) { | |||
if (StringUtils.isEmpty(param)) { | |||
return new HashMap<>(); | |||
} | |||
try { | |||
return objectMapper.readValue(param, new TypeReference<Map<String, Object>>() { | |||
}); | |||
} catch (IOException e) { | |||
log.error(e.getMessage()); | |||
return new HashMap<>(); | |||
} | |||
} | |||
/** | |||
* map 取 model list | |||
* | |||
* @param map | |||
* @return | |||
* @throws Exception | |||
*/ | |||
public static <T> List<T> getMapTs(Map map, String key, Class<T> clazz) { | |||
if (!MapUtils.isEmpty(map)) { | |||
Object obj = map.get(key); | |||
if (obj != null) { | |||
ObjectMapper mapper = new ObjectMapper(); | |||
try { | |||
String objStr = mapper.writeValueAsString(obj); | |||
JavaType type = mapper.getTypeFactory().constructCollectionType(List.class, clazz); | |||
return mapper.readValue(objStr, type); | |||
} catch (Exception ex) { | |||
log.error(ex.getMessage()); | |||
return new ArrayList<>(); | |||
} | |||
} | |||
} | |||
return new ArrayList<>(); | |||
} | |||
public static JSONObject getAthenaParameter(String messageBody){ | |||
JSONObject stdData = JSONObject.parseObject(messageBody).getJSONObject("std_data"); | |||
JSONObject parameter = stdData.getJSONObject("parameter"); | |||
return parameter; | |||
} | |||
} |
@ -0,0 +1,73 @@ | |||
package com.digiwin.athena.app.infra.dto.order; | |||
import com.google.gson.annotations.SerializedName; | |||
import lombok.AllArgsConstructor; | |||
import lombok.Builder; | |||
import lombok.Data; | |||
import lombok.NoArgsConstructor; | |||
import java.util.Date; | |||
/** | |||
* 人资报道对象 ca_cim_staff | |||
* | |||
* @author zhenggl | |||
* @date 2023-04-28 | |||
*/ | |||
@Data | |||
@AllArgsConstructor | |||
@NoArgsConstructor | |||
@Builder | |||
public class StaffDTO | |||
{ | |||
@SerializedName("id") | |||
private Long id; | |||
/** 员工编号 */ | |||
@SerializedName("employee_no") | |||
private String employeeNo; | |||
/** 员工名称 */ | |||
@SerializedName("employee_name") | |||
private String employeeName; | |||
/** 员工英文名称 */ | |||
@SerializedName("en_employee_name") | |||
private String enEmployeeName; | |||
/** 手机号码 */ | |||
@SerializedName("mobile_no") | |||
private Long mobileNo; | |||
/** 电子邮件 */ | |||
@SerializedName("email") | |||
private String email; | |||
/** 状态 */ | |||
@SerializedName("status") | |||
private Integer status = 1; | |||
/** 数据状态 */ | |||
@SerializedName("tab_status") | |||
private Integer tabStatus = 0; | |||
/** 报道日期 */ | |||
@SerializedName("register_date") | |||
private Date registerDate; | |||
/** 时间戳 */ | |||
@SerializedName("timestamp") | |||
private String timestamp; | |||
//==========冗余============== | |||
@SerializedName("register_personnel_id") | |||
public Long registerPersonnelId; | |||
public StaffDTO(String employeeNo, Long registerPersonnelId) { | |||
this.employeeNo = employeeNo; | |||
this.registerPersonnelId = registerPersonnelId; | |||
} | |||
} |
@ -0,0 +1,69 @@ | |||
package com.digiwin.athena.app.infra.entity; | |||
import java.util.Date; | |||
import com.baomidou.mybatisplus.annotation.TableName; | |||
import com.digiwin.athena.opt.persistence.domain.BaseMgrEntity; | |||
import com.google.gson.annotations.SerializedName; | |||
import lombok.AllArgsConstructor; | |||
import lombok.Builder; | |||
import lombok.Data; | |||
import lombok.NoArgsConstructor; | |||
/** | |||
* 人资报道对象 ca_cim_staff | |||
* | |||
* @author zhenggl | |||
* @date 2023-04-28 | |||
*/ | |||
@Data | |||
@AllArgsConstructor | |||
@NoArgsConstructor | |||
@Builder | |||
@TableName(value = "ca_cim_staff", autoResultMap = true) | |||
public class StaffEntity extends BaseMgrEntity<StaffEntity> | |||
{ | |||
private static final long serialVersionUID = 1L; | |||
/** $column.columnComment */ | |||
private Long id; | |||
/** 员工编号 */ | |||
@SerializedName("employee_no") | |||
private String employeeNo; | |||
/** 员工名称 */ | |||
@SerializedName("employee_name") | |||
private String employeeName; | |||
/** 员工英文名称 */ | |||
@SerializedName("en_employee_name") | |||
private String enEmployeeName; | |||
/** 手机号码 */ | |||
@SerializedName("mobile_no") | |||
private Long mobileNo; | |||
/** 电子邮件 */ | |||
@SerializedName("email") | |||
private String email; | |||
/** 状态 */ | |||
@SerializedName("status") | |||
private Integer status; | |||
/** 数据状态 */ | |||
@SerializedName("tab_status") | |||
private Integer tabStatus; | |||
/** 报道日期 */ | |||
@SerializedName("register_date") | |||
private Date registerDate; | |||
/** 时间戳 */ | |||
@SerializedName("timestamp") | |||
private String timestamp; | |||
} |
@ -0,0 +1,12 @@ | |||
package com.digiwin.athena.app.infra.repository; | |||
import com.digiwin.athena.app.infra.entity.StaffEntity; | |||
import com.digiwin.athena.opt.persistence.repository.BaseRepository; | |||
/** | |||
* @Auther: zhenggl | |||
* @Date: 2023/4/28 | |||
*/ | |||
public interface StaffRepository extends BaseRepository<StaffEntity> { | |||
} |
@ -0,0 +1,7 @@ | |||
package com.digiwin.athena.app.infra.service; | |||
import com.digiwin.athena.app.infra.entity.StaffEntity; | |||
import com.digiwin.athena.opt.persistence.service.IBaseService; | |||
public interface StaffService extends IBaseService<StaffEntity> { | |||
} |
@ -0,0 +1,16 @@ | |||
package com.digiwin.athena.app.infra.service.impl; | |||
import com.digiwin.athena.app.infra.entity.StaffEntity; | |||
import com.digiwin.athena.app.infra.repository.StaffRepository; | |||
import com.digiwin.athena.app.infra.service.StaffService; | |||
import com.digiwin.athena.opt.persistence.service.impl.AbsBaseService; | |||
import org.springframework.stereotype.Service; | |||
/** | |||
* @author zhenggl | |||
* create: 2023-04-28 | |||
* Description: | |||
*/ | |||
@Service | |||
public class StaffServiceImpl extends AbsBaseService<StaffRepository, StaffEntity> implements StaffService { | |||
} |
@ -0,0 +1,55 @@ | |||
package com.digiwin.athena.app.provider; | |||
import com.digiwin.app.service.DWEAIResult; | |||
import com.digiwin.app.service.DWService; | |||
import com.digiwin.app.service.eai.EAIService; | |||
import com.digiwin.athena.app.service.staff.StaffUtil; | |||
import java.util.Map; | |||
/** | |||
* @Auther: zhenggl | |||
* @Date: 2023/4/28 | |||
*/ | |||
public interface StaffEAIService extends DWService { | |||
/** | |||
* 新人报道修改 | |||
* @param headers | |||
* @param messageBody | |||
* @return | |||
* @throws Exception | |||
*/ | |||
@EAIService(id = StaffUtil.DEMO_WAIT_REGISTER_PERSONNEL_INFO_UPDATE) | |||
DWEAIResult update(Map<String, String> headers, String messageBody) throws Exception; | |||
/** | |||
* 新人报道侦测 | |||
* @param headers | |||
* @param messageBody | |||
* @return | |||
* @throws Exception | |||
*/ | |||
@EAIService(id = StaffUtil.DEMO_WAIT_REGISTER_PERSONNEL_INFO_GET) | |||
DWEAIResult get(Map<String, String> headers, String messageBody) throws Exception; | |||
/** | |||
* 新人报道查询 | |||
* @param headers | |||
* @param messageBody | |||
* @return | |||
* @throws Exception | |||
*/ | |||
@EAIService(id = StaffUtil.DEMO_WAIT_REGISTER_PERSONNEL_INFO_QUERY) | |||
DWEAIResult query(Map<String, String> headers, String messageBody) throws Exception; | |||
/** | |||
* 新人报道创建 | |||
* @param headers | |||
* @param messageBody | |||
* @return | |||
* @throws Exception | |||
*/ | |||
@EAIService(id = StaffUtil.DEMO_WAIT_REGISTER_PERSONNEL_INFO_CREATE) | |||
DWEAIResult create(Map<String, String> headers, String messageBody) throws Exception; | |||
} |
@ -0,0 +1,40 @@ | |||
package com.digiwin.athena.app.provider.impl; | |||
import com.digiwin.app.service.DWEAIResult; | |||
import com.digiwin.athena.app.provider.StaffEAIService; | |||
import com.digiwin.athena.app.service.staff.StaffUtil; | |||
import com.digiwin.athena.opt.common.eai.service.EAIServiceContext; | |||
import javax.annotation.Resource; | |||
import java.util.Map; | |||
/** | |||
* @Auther: zhenggl | |||
* @Date: 2023/4/28 | |||
*/ | |||
public class StaffEAIServiceImpl implements StaffEAIService { | |||
@Resource | |||
private EAIServiceContext eaiServiceContext; | |||
@Override | |||
public DWEAIResult update(Map<String, String> headers, String messageBody) throws Exception { | |||
return eaiServiceContext.execute(StaffUtil.DEMO_WAIT_REGISTER_PERSONNEL_INFO_UPDATE,headers,messageBody); | |||
} | |||
@Override | |||
public DWEAIResult get(Map<String, String> headers, String messageBody) throws Exception { | |||
return eaiServiceContext.execute(StaffUtil.DEMO_WAIT_REGISTER_PERSONNEL_INFO_GET,headers,messageBody); | |||
} | |||
@Override | |||
public DWEAIResult query(Map<String, String> headers, String messageBody) throws Exception { | |||
return eaiServiceContext.execute(StaffUtil.DEMO_WAIT_REGISTER_PERSONNEL_INFO_QUERY,headers,messageBody); | |||
} | |||
@Override | |||
public DWEAIResult create(Map<String, String> headers, String messageBody) throws Exception { | |||
return eaiServiceContext.execute(StaffUtil.DEMO_WAIT_REGISTER_PERSONNEL_INFO_CREATE,headers,messageBody); | |||
} | |||
} |
@ -0,0 +1,69 @@ | |||
package com.digiwin.athena.app.service.staff; | |||
import com.alibaba.fastjson.JSONObject; | |||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||
import com.digiwin.app.container.exceptions.DWRuntimeException; | |||
import com.digiwin.app.service.DWEAIResult; | |||
import com.digiwin.athena.app.infra.common.utils.BeanCopyUtil; | |||
import com.digiwin.athena.app.infra.dto.order.StaffDTO; | |||
import com.digiwin.athena.app.infra.entity.StaffEntity; | |||
import com.digiwin.athena.app.infra.repository.StaffRepository; | |||
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.service.AbsEAIService; | |||
import com.digiwin.athena.opt.common.security.SecurityUtil; | |||
import org.springframework.util.CollectionUtils; | |||
import javax.annotation.Resource; | |||
import java.util.HashMap; | |||
import java.util.List; | |||
import java.util.Map; | |||
import java.util.stream.Collectors; | |||
/** | |||
* @Auther: zhenggl | |||
* @Date: 2023/4/28 | |||
*/ | |||
public class StaffCreateEAIService extends AbsEAIService { | |||
@Resource | |||
private StaffRepository staffRepository; | |||
@Resource | |||
private StaffService staffService; | |||
@Override | |||
public String getServiceName() { | |||
return StaffUtil.DEMO_WAIT_REGISTER_PERSONNEL_INFO_CREATE; | |||
} | |||
@Override | |||
public DWEAIResult execute(Map<String, String> headers, String messageBody) throws Exception { | |||
//反序列化字段 | |||
EAIRequest request = new EAIRequest(messageBody); | |||
List<StaffDTO> staffList = request.getObject("wait_register_personnel", StaffUtil.LIST_DTO_STAFF); | |||
//判断编号跟邮箱是否存在 | |||
LambdaQueryWrapper<StaffEntity> lmq = new LambdaQueryWrapper<>(); | |||
lmq.or(queryWrapperInner -> { | |||
for (StaffDTO staffDTO : staffList) { | |||
queryWrapperInner.or( | |||
wrapper->wrapper | |||
.eq(StaffEntity::getEmployeeNo,staffDTO.getEmployeeNo()) | |||
); | |||
queryWrapperInner.or( | |||
wrapper->wrapper | |||
.eq(StaffEntity::getEmail,staffDTO.getEmail()) | |||
); | |||
} | |||
}); | |||
List<StaffEntity> staffEntities = staffRepository.selectList(lmq); | |||
if (!CollectionUtils.isEmpty(staffEntities)){ | |||
throw new DWRuntimeException("员工编号或邮箱重复"); | |||
} | |||
List<StaffEntity> staffEntityList = BeanCopyUtil.copyList(staffList, StaffEntity.class); | |||
staffService.saveBatch(staffEntityList); | |||
List<StaffDTO> collect = staffEntities.stream().map(item -> new StaffDTO(item.getEmployeeNo(), item.getId())).collect(Collectors.toList()); | |||
return EAIUtil.buildEAIResult(new JSONObject().fluentPut("wait_register_personnel",collect)); | |||
} | |||
} |
@ -0,0 +1,60 @@ | |||
package com.digiwin.athena.app.service.staff; | |||
import com.alibaba.fastjson.JSONObject; | |||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; | |||
import com.digiwin.app.service.DWEAIResult; | |||
import com.digiwin.athena.app.infra.common.enums.TabStatusEnums; | |||
import com.digiwin.athena.app.infra.entity.StaffEntity; | |||
import com.digiwin.athena.app.infra.repository.StaffRepository; | |||
import com.digiwin.athena.app.infra.service.StaffService; | |||
import com.digiwin.athena.opt.common.eai.EAIUtil; | |||
import com.digiwin.athena.opt.common.eai.service.AbsEAIService; | |||
import com.digiwin.athena.opt.common.security.SecurityUtil; | |||
import org.springframework.transaction.annotation.Transactional; | |||
import org.springframework.util.CollectionUtils; | |||
import javax.annotation.Resource; | |||
import java.util.List; | |||
import java.util.Map; | |||
import java.util.stream.Collectors; | |||
/** | |||
* @Auther: zhenggl | |||
* @Date: 2023/4/28 | |||
*/ | |||
public class StaffGetEAIService extends AbsEAIService { | |||
@Resource | |||
private StaffRepository staffRepository; | |||
@Resource | |||
private StaffService staffService; | |||
@Override | |||
public String getServiceName() { | |||
return StaffUtil.DEMO_WAIT_REGISTER_PERSONNEL_INFO_GET; | |||
} | |||
@Override | |||
@Transactional(rollbackFor = Exception.class) | |||
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()); | |||
}); | |||
} | |||
return EAIUtil.buildEAIResult(new JSONObject().fluentPut("wait_register_personnel",staffEntities)); | |||
} | |||
} |
@ -0,0 +1,42 @@ | |||
package com.digiwin.athena.app.service.staff; | |||
import com.alibaba.fastjson.JSONObject; | |||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||
import com.digiwin.app.service.DWEAIResult; | |||
import com.digiwin.athena.app.infra.common.enums.TabStatusEnums; | |||
import com.digiwin.athena.app.infra.dto.order.StaffDTO; | |||
import com.digiwin.athena.app.infra.entity.StaffEntity; | |||
import com.digiwin.athena.app.infra.repository.StaffRepository; | |||
import com.digiwin.athena.opt.common.eai.EAIRequest; | |||
import com.digiwin.athena.opt.common.eai.EAIUtil; | |||
import com.digiwin.athena.opt.common.eai.service.AbsEAIService; | |||
import com.digiwin.athena.opt.common.security.SecurityUtil; | |||
import javax.annotation.Resource; | |||
import java.util.List; | |||
import java.util.Map; | |||
/** | |||
* @Auther: zhenggl | |||
* @Date: 2023/4/28 | |||
*/ | |||
public class StaffQueryEAIService extends AbsEAIService { | |||
@Resource | |||
private StaffRepository staffRepository; | |||
@Override | |||
public String getServiceName() { | |||
return StaffUtil.DEMO_WAIT_REGISTER_PERSONNEL_INFO_QUERY; | |||
} | |||
@Override | |||
public DWEAIResult execute(Map<String, String> headers, String messageBody) throws Exception { | |||
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); | |||
return EAIUtil.buildEAIResult(new JSONObject().fluentPut("wait_register_personnel",staffEntities)); | |||
} | |||
} |
@ -0,0 +1,47 @@ | |||
package com.digiwin.athena.app.service.staff; | |||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; | |||
import com.digiwin.app.service.DWEAIResult; | |||
import com.digiwin.athena.app.infra.common.enums.TabStatusEnums; | |||
import com.digiwin.athena.app.infra.entity.StaffEntity; | |||
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.service.AbsEAIService; | |||
import org.springframework.util.CollectionUtils; | |||
import javax.annotation.Resource; | |||
import java.util.ArrayList; | |||
import java.util.HashMap; | |||
import java.util.List; | |||
import java.util.Map; | |||
/** | |||
* @Auther: zhenggl | |||
* @Date: 2023/4/28 | |||
*/ | |||
public class StaffUpdateEAIService extends AbsEAIService { | |||
@Resource | |||
private StaffService staffService; | |||
@Override | |||
public String getServiceName() { | |||
return StaffUtil.DEMO_WAIT_REGISTER_PERSONNEL_INFO_UPDATE; | |||
} | |||
@Override | |||
public DWEAIResult execute(Map<String, String> headers, String messageBody) throws Exception { | |||
//反序列化字段 | |||
EAIRequest request = new EAIRequest(messageBody); | |||
List<Integer> staffList = request.getObject("wait_register_personnel", new ArrayList<Integer>().getClass()); | |||
if (!CollectionUtils.isEmpty(staffList)){ | |||
LambdaUpdateWrapper<StaffEntity> lmu = new LambdaUpdateWrapper<>(); | |||
lmu.set(StaffEntity::getTabStatus, TabStatusEnums.COMPLETED.getValue()); | |||
lmu.in(StaffEntity::getId,staffList); | |||
staffService.update(lmu); | |||
} | |||
return EAIUtil.buildEAIResult(new HashMap<>()); | |||
} | |||
} |
@ -0,0 +1,27 @@ | |||
package com.digiwin.athena.app.service.staff; | |||
import com.alibaba.fastjson.TypeReference; | |||
import com.digiwin.athena.app.infra.dto.order.StaffDTO; | |||
import java.util.List; | |||
/** | |||
* @Auther: zhenggl | |||
* @Date: 2023/4/28 | |||
*/ | |||
public class StaffUtil { | |||
/** | |||
* 新人报道增改查 | |||
* @Author zhenggl | |||
* @Param | |||
* @return | |||
* @Throw | |||
*/ | |||
public static final String DEMO_WAIT_REGISTER_PERSONNEL_INFO_CREATE = "demo.wait.register.personnel.info.create"; | |||
public static final String DEMO_WAIT_REGISTER_PERSONNEL_INFO_UPDATE = "demo.wait.register.personnel.info.update"; | |||
public static final String DEMO_WAIT_REGISTER_PERSONNEL_INFO_GET = "demo.wait.register.personnel.info.get"; | |||
public static final String DEMO_WAIT_REGISTER_PERSONNEL_INFO_QUERY = "demo.wait.register.personnel.info.query"; | |||
public static final TypeReference<List<StaffDTO>> LIST_DTO_STAFF = new TypeReference<List<StaffDTO>>() { | |||
}; | |||
} |